0

I have created custom admin grid(without ui component). While edit action it needs to get id from DB to display the existing data in form. Grid.php

$this->addColumn(
                'edit', [
            'header' => __('Edit'),
            'type' => 'action',

            'actions' => [
                [
                    'caption' => __('Edit'),

                    'url' => $this->_url->getUrl('*/*/*', ['id' => '1', 'active_tab' => 'upload']),
                ],
//                
            ],
            'filter' => false,
            'sortable' => false,
            'header_css_class' => 'col-action',
            'column_css_class' => 'col-action'
                ]
        );

In above code, I have given id statically as 1 and it loads the data and displayed in the form, but now I need to get Id from DB dynamically, Please provide me a solution

1

Add your 'field' => 'id' after url. also same in 'getter' => 'getId',

$this->addColumn(
            'edit',
            [
                'header' => __('Action'),
                'type' => 'action',
                'getter' => 'getId',
                'actions' => [
                    [
                        'caption' => __('Edit'),
                        'url' => [
                            'base' => '*/*/edit',
                            'params' => []
                        ],
                        'field' => 'id'
                    ]
                ],
                'filter' => false,
                'sortable' => false,
                'label' =>  __('Edit'),
                'index' => 'stores',
                'header_css_class' => 'col-action',
                'column_css_class' => 'col-action'
            ]
        );   
  • Thanks for the response, But it is failed to frame the url for edit action – Jaisa Mar 20 '18 at 7:20
  • @Sri did you change id with your column? – Qaisar Satti Mar 20 '18 at 7:25
  • Yes. My grid column id is also ' id ' – Jaisa Mar 20 '18 at 7:28
  • @Sri you check here what you are missing. i can't find any error in this code. .magento.stackexchange.com/questions/86884/… – Qaisar Satti Mar 20 '18 at 7:39

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.