Add Dynamic Grid Structure In Admin Config

Adding Dynamic Row in store config solves many problems for a developer as well as for the Admin. For example, by using this, one doesn’t require to use a custom Grid section in another part of the admin and fetch data from a custom table for specific work. So by using this we can also save Our time and it’s quite a user friendly.

Let’s start with the Basic Module Structure First. Here I assume one should already Have Basic knowledge about Module and its structure, if not please refer to this link first.

Now, as we are now familiar with the Basic module structure Lets proceed further. Here I have taken Module name as Excellence_Grid.

We will provide the access or configuration in Store configuration, Section Which is at Stores -> Configuration (under settings).

For this, we need to create the instruction for configuring. So, we will create a system.xml file in our module first.

Excellence/Grid/etc/adminhtml/system.xml

In above, we have added the configuration section in
STORES > Settings > Configuration > GENERAL > General > Quantity Ranges.

In the above, we have mentioned the block class through which we will create columns in the grid.

So, create a block class
Excellence\Grid\Block\Adminhtml\Form\Field\Ranges

Now, as we have defined the grid section, now we have to set the values which have to be dynamic. For this, we need to create a block file at
Excellence\Grid\Block\Adminhtml\Form\Field\TaxColumn

After That Just Run These Commands:
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy -f
php bin/magento cache:clean
php bin/magento cache:f
lush

Once done, you will be able to see the output like this.

colorpicker