0

I had created a Custom Admin Grid by using uiComponent in which I am showing Order Details, please check below Screenshot

enter image description here

I had created System Configuration to show IGST, CST, SGST field or not, if it enables from admin then I will show this in grid otherwise not.

Code:

         <column name="price_igst">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="filter" xsi:type="string">textRange</item>
                    <item name="label" xsi:type="string" translate="true">IGST</item>
                </item>
            </argument>
        </column>
        <column name="price_cgst">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="filter" xsi:type="string">textRange</item>
                    <item name="label" xsi:type="string" translate="true">CGST</item>
                </item>
            </argument>
        </column>
        <column name="price_sgst">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="filter" xsi:type="string">textRange</item>
                    <item name="label" xsi:type="string" translate="true">SGST</item>
                </item>
            </argument>
        </column>

Please help me how to do it?

2
  • <argument name="testHelperWithParams" xsi:type="helper" helper="Magento\Framework\View\Layout\Argument\Handler\TestHelper::testMethod"> Have you tried this? I don't know how it works in UI component but it works in layout files.
    – Mohit Rane
    Jul 23, 2019 at 13:10
  • 1
    @MohitRane I don't think it will work in UiComponent, I will do some RND and post the answer soon.
    – temper
    Jul 24, 2019 at 4:28

1 Answer 1

1

Need to add to your UI component a new tag

<container name="listing_top">
    <argument name="data" xsi:type="array">
        <item name="config" xsi:type="array">
            <item name="template" xsi:type="string">ui/grid/toolbar</item>
        </item>
    </argument>
    <container name="columns_controls">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="columnsData" xsi:type="array">
                    <item name="provider" xsi:type="string">you.provaider.name</item>
                </item>
                <item name="component" xsi:type="string">Magento_Ui/js/grid/controls/columns</item>
                <item name="displayArea" xsi:type="string">dataGridActions</item>
            </item>
        </argument>
    </container>
</container>

if you have container listing_top in your ui component file, just add the tag columns_control to it.

1
  • 1
    Current I am already managing it by column control but I need to remove the field from column control aswell if it is disabled from admin configuration
    – temper
    Jul 23, 2019 at 7:22

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.