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
asked Mar 20, 2018 at 6:52
1 Answer 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'
]
);
answered Mar 20, 2018 at 7:09
-
Thanks for the response, But it is failed to frame the url for edit actionJaisa– Jaisa2018年03月20日 07:20:45 +00:00Commented Mar 20, 2018 at 7:20
-
@Sri did you change
idwith your column?Qaisar Satti– Qaisar Satti2018年03月20日 07:25:11 +00:00Commented Mar 20, 2018 at 7:25 -
Yes. My grid column id is also ' id 'Jaisa– Jaisa2018年03月20日 07:28:02 +00:00Commented Mar 20, 2018 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– Qaisar Satti2018年03月20日 07:39:18 +00:00Commented Mar 20, 2018 at 7:39
default