1

I have a column called goods. I can enter the number inside that column and save. After save I don't want to show the entry in the grid. It should be empty. I want to show only the column name as goods but I don't want to show the entry. Please help. Thanks in advance.

2 Answers 2

0

If you want to show just column name and hide to its values just do follow things

1) Go to your custom module -> app/code/Module/Backendgrid/Block/Adminhtml/Backendgrid/Grid.php

2) Go to protected function _prepareColumns() method

3) Find column whose value you want to hide like

                $this->addColumn(
                    'name',
                    [
                        'header' => __('name')
                        //'index' => 'name',
                    ]
                );

4) run this commands php bin/magento cache:clean && php bin/magento cache:flush

1
  • I have not used block.I used UI component Commented Nov 21, 2018 at 10:30
0

Inside your UI component file you will find a column tag with a name attribute which is your column name, like below example:

<column name="created_at" class="Magento\Ui\Component\Listing\Columns\Date" component="Magento_Ui/js/grid/columns/date">
            <settings>
                <filter>dateRange</filter>
                <dataType>date</dataType>
                <label translate="true">Purchase Date</label>
                <sorting>desc</sorting>
            </settings>
</column>

You can comment it or delete that part of the code. Above created_at is the name of the column that you want to delete.

5
  • if we comment that inline edit will not work for that column Commented Nov 21, 2018 at 11:42
  • 1
    Try changing the name attribute value i.e name of the column to something that does not exists in your database columns. Commented Nov 21, 2018 at 11:58
  • while saving the data undefined index error is coming. Commented Nov 21, 2018 at 12:16
  • Ok understood, i think you will have to change the code where the data is getting saved, so that you can skip that index that you do not wish to save in the database. Commented Nov 21, 2018 at 12:21
  • HI, Sourabh finally it's working. whatever the dummy column name we enter in the UI component file same name we should give in the inline edit file. Thank you so much for the help. Commented Nov 23, 2018 at 6:03

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.