2

I developed site in magento 2. i create a custom module. now i want to add Dynamic Rows Component to my module i read document.

http://devdocs.magento.com/guides/v2.1/ui-components/ui_dynamic_rows.html

But i know magento at beginner level. and i can't able to understand after reading document. i can't understand where on which file should i changed.

Teja Bhagavan Kollepara
3,8275 gold badges33 silver badges69 bronze badges
asked Aug 1, 2016 at 10:01

1 Answer 1

2

I give you idea how you can do it not whole answer. You create DataProvider in your module this is sample code

protected function getSelectTypeGridConfig($sortOrder) {
 return [
 'arguments' => [
 'data' => [
 'config' => [
 'addButtonLabel' => __('Add Value'),
 'componentType' => DynamicRows::NAME,
 'component' => 'Magento_Ui/js/dynamic-rows/dynamic-rows',
 'additionalClasses' => 'admin__field-wide',
 'deleteProperty' => static::FIELD_IS_DELETE,
 'deleteValue' => '1',
 'renderDefaultRecord' => false,
 'sortOrder' => $sortOrder,
 ],
 ],
 ],
 'children' => [
 'record' => [
 'arguments' => [
 'data' => [
 'config' => [
 'componentType' => Container::NAME,
 'component' => 'Magento_Ui/js/dynamic-rows/record',
 'positionProvider' => static::FIELD_SORT_ORDER_NAME,
 'isTemplate' => true,
 'is_collection' => true,
 ],
 ],
 ],
 'children' => [
 static::FIELD_CUSTOM_NAME => $this->getCustomFieldConfig(10)
 ]
 ]
 ]
 ];
}
protected function getCustomFieldConfig($sortOrder, array $options = []) {
 return array_replace_recursive(
 [
 'arguments' => [
 'data' => [
 'config' => [
 'label' => __('Test'),
 'componentType' => Field::NAME,
 'formElement' => Input::NAME,
 'dataScope' => static::FIELD_CUSTOM_NAME,
 'dataType' => Text::NAME,
 'sortOrder' => $sortOrder,
 ],
 ],
 ],
 ], $options
 );
}

for more detail please check following file Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\CustomOptions.php

answered Aug 1, 2016 at 13:36
1
  • how can we limit the dynamic rows? i need to set max 10. Commented Jan 27, 2021 at 16:50

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.