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

asked Mar 20, 2018 at 6:52

1 Answer 1

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
4
  • Thanks for the response, But it is failed to frame the url for edit action Commented Mar 20, 2018 at 7:20
  • @Sri did you change id with your column? Commented Mar 20, 2018 at 7:25
  • Yes. My grid column id is also ' id ' Commented 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/… Commented Mar 20, 2018 at 7:39

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.