2

Is it possible to add blank column into a custom admin grid module? this is the code of my ui_component

<columns name="spinner_columns">
    <selectionsColumn name="ids">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="resizeEnabled" xsi:type="boolean">false</item>
                <item name="resizeDefaultWidth" xsi:type="string">55</item>
                <item name="indexField" xsi:type="string">entity_id</item>
                <item name="sortOrder" xsi:type="number">5</item>
            </item>
        </argument>
    </selectionsColumn>
    <column name="increment_id">
        <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">Order id</item>
                <item name="sortOrder" xsi:type="number">10</item>
            </item>
        </argument>
    </column>
    <column name="company">
        <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">company</item>
                <item name="sortOrder" xsi:type="number">15</item>
            </item>
        </argument>
    </column>
    <column name="created_at" class="Magento\Ui\Component\Listing\Columns\Date">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="filter" xsi:type="string">dateRange</item>
                <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item>
                <item name="dataType" xsi:type="string">date</item>
                <item name="label" xsi:type="string" translate="true">Created</item>
                <item name="sortOrder" xsi:type="number">20</item>                    
            </item>
        </argument>
    </column>
    <column name="updated_at" class="Magento\Ui\Component\Listing\Columns\Date">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="filter" xsi:type="string">dateRange</item>
                <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item>
                <item name="dataType" xsi:type="string">date</item>
                <item name="label" xsi:type="string" translate="true">Modified</item>
            </item>
        </argument>
    </column>
</columns>
4
  • no offense, but why would you want that? Feb 22, 2019 at 9:49
  • @PhilippSander easily for copy&paste for other usage
    – hkguile
    Feb 22, 2019 at 9:51
  • copy&paste? a blank column? Feb 22, 2019 at 9:51
  • yes, if no blank column, user have to insert column using excel
    – hkguile
    Feb 22, 2019 at 9:52

1 Answer 1

1

Yes, you can add blank column in admin grid.

Just add below code in your ui-component xml file.

<columns name="spinner_columns">
    <column name="id">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="filter" xsi:type="string">textRange</item>
                <item name="sorting" xsi:type="string">asc</item>
                <item name="label" xsi:type="string" translate="true">ID</item>
            </item>
        </argument>
    </column>
</columns>

This code will add blank column in your admin grid.

4
  • Just tried, "Something went wrong" modal was shown
    – hkguile
    Feb 22, 2019 at 9:58
  • 1
    name="id" => name="" seems work
    – hkguile
    Feb 22, 2019 at 10:01
  • You must have to give name for column. You can not pass blank value for name attribute. Feb 22, 2019 at 10:56
  • If you don't want to add data in column then pass any dummy name. And if you want data in column then you have to pass database table field name as name attribute value like name="<table_fieldName>" Feb 22, 2019 at 10:57

Your Answer

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

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