1

How to rearrange column of product grid ?

enter image description here

2
  • drag and drop maybe?
    – Marius
    Mar 7, 2016 at 8:36
  • I want to custom code, I tried to edit in gird.php but it did not changed.
    – MrTo-Kane
    Mar 7, 2016 at 8:42

3 Answers 3

2

Change in below file

vendor\magento\module-catalog\view\adminhtml\ui_component\product_listing.xml

There is code for status column like below adjust it as per you want

<column name="status">
            <argument name="data" xsi:type="array">
                <item name="options" xsi:type="object">Magento\Catalog\Model\Product\Attribute\Source\Status</item>
                <item name="config" xsi:type="array">
                    <item name="filter" xsi:type="string">select</item>
                    <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item>
                    <item name="add_field" xsi:type="boolean">true</item>
                    <item name="dataType" xsi:type="string">select</item>
                    <item name="label" xsi:type="string" translate="true">Status</item>
                    <item name="sortOrder" xsi:type="number">90</item>
                </item>
            </argument>
 </column>
1

I solved my problem below: In Grid.php of block I override method _prepareColumns

.........       
$this->addColumnAfter(
                'status',
                [
                        'header' => __('Status'),
                        'index' => 'status',
                        'type' => 'options',
                        'options' => $this->_status->getOptionArray()
                ],
                'entity_id'
        );
...............
1
1

No code required, drag and drop the column headers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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