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.

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

  • I have not used block.I used UI component – Dilip Nov 21 '18 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.

  • if we comment that inline edit will not work for that column – Dilip Nov 21 '18 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. – Sourabh Kumar Sharma Nov 21 '18 at 11:58
  • while saving the data undefined index error is coming. – Dilip Nov 21 '18 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. – Sourabh Kumar Sharma Nov 21 '18 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. – Dilip Nov 23 '18 at 6:03

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.