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.

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.