Inline edit grid magento 2How can i rewrite TierPrice Block in Magento2Adminhtml grid inline editing - won't workImplement massactions in grid using ui_component magento2Custom Grid in magento 2 without FormMagento2 : How to enable inline edit in catalog grid without changing source code?Change Sort Order of Edit Action Customer Grid ColumnInline edit not working in gridMagento 2 save grid data from admin formMagento 2 - Backend grid inline edit not doing anything at allMagento 2 : How to get selected record from ui form fieldset listing grid in controller?
Will a paper be retracted if a flaw in released software code invalidates its central idea?
In Pokémon Go, why does one of my Pikachu have an option to evolve, but another one doesn't?
Why should public servants be apolitical?
Why couldn't soldiers sight their own weapons without officers' orders?
HttpResponse[Status=BAD_REQUEST, StatusCode=400]
Was the first German bombing of London an accident?
Traveling from Germany to other countries by train?
Does the length of a password for Wi-Fi affect speed?
Short story about a teenager who has his brain replaced with a microchip (Psychological Horror)
How do I say "Outdoor Pre-show"
How do I get the =LEFT function in excel, to also take the number zero as the first number?
How can glass marbles naturally occur in a desert?
Unexpected route on a flight from USA to Europe
Is it allowed and safe to carry a passenger / non-pilot in the front seat of a small general aviation airplane?
Should I take out a personal loan to pay off credit card debt?
If there were no space agencies, could a person go to space?
What are the examples (applications) of the MIPs in which the objective function has nonzero coefficients for only continuous variables?
Did Apollo leave poop on the moon?
French equivalent of "Make leaps and bounds"
How can I make Ubuntu run well (including with wifi) on a 32-bit machine?
How to explain to a team that the project they will work for 6 months will 100% fail?
Secure my password from unsafe servers
What word can be used to describe a bug in a movie?
Does the United States guarantee any unique freedoms?
Inline edit grid magento 2
How can i rewrite TierPrice Block in Magento2Adminhtml grid inline editing - won't workImplement massactions in grid using ui_component magento2Custom Grid in magento 2 without FormMagento2 : How to enable inline edit in catalog grid without changing source code?Change Sort Order of Edit Action Customer Grid ColumnInline edit not working in gridMagento 2 save grid data from admin formMagento 2 - Backend grid inline edit not doing anything at allMagento 2 : How to get selected record from ui form fieldset listing grid in controller?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
How to create Inline Edit in grid? I need controller file or only do this in view ui_component?
I created this in ui_component but not working
<item name="childDefaults" xsi:type="array">
<item name="fieldAction" xsi:type="array">
<item name="provider" xsi:type="string">test_mytesting_index.test_mytesting_index.test_mytesting_columns_editor</item>
<item name="target" xsi:type="string">startEdit</item>
<item name="params" xsi:type="array">
<item name="0" xsi:type="string">$ $.$data.rowIndex </item>
<item name="1" xsi:type="boolean">true</item>
</item>
</item>
magento2 admin grid
add a comment |
How to create Inline Edit in grid? I need controller file or only do this in view ui_component?
I created this in ui_component but not working
<item name="childDefaults" xsi:type="array">
<item name="fieldAction" xsi:type="array">
<item name="provider" xsi:type="string">test_mytesting_index.test_mytesting_index.test_mytesting_columns_editor</item>
<item name="target" xsi:type="string">startEdit</item>
<item name="params" xsi:type="array">
<item name="0" xsi:type="string">$ $.$data.rowIndex </item>
<item name="1" xsi:type="boolean">true</item>
</item>
</item>
magento2 admin grid
1
You need a controller to save the values you change in inline-grid.
– aravind
Jul 29 at 7:34
But I can not change anything in my grid
– Tomalo
Jul 29 at 7:36
add a comment |
How to create Inline Edit in grid? I need controller file or only do this in view ui_component?
I created this in ui_component but not working
<item name="childDefaults" xsi:type="array">
<item name="fieldAction" xsi:type="array">
<item name="provider" xsi:type="string">test_mytesting_index.test_mytesting_index.test_mytesting_columns_editor</item>
<item name="target" xsi:type="string">startEdit</item>
<item name="params" xsi:type="array">
<item name="0" xsi:type="string">$ $.$data.rowIndex </item>
<item name="1" xsi:type="boolean">true</item>
</item>
</item>
magento2 admin grid
How to create Inline Edit in grid? I need controller file or only do this in view ui_component?
I created this in ui_component but not working
<item name="childDefaults" xsi:type="array">
<item name="fieldAction" xsi:type="array">
<item name="provider" xsi:type="string">test_mytesting_index.test_mytesting_index.test_mytesting_columns_editor</item>
<item name="target" xsi:type="string">startEdit</item>
<item name="params" xsi:type="array">
<item name="0" xsi:type="string">$ $.$data.rowIndex </item>
<item name="1" xsi:type="boolean">true</item>
</item>
</item>
magento2 admin grid
magento2 admin grid
edited Jul 29 at 7:40
Mohit Rane
1,21318 bronze badges
1,21318 bronze badges
asked Jul 29 at 7:31
TomaloTomalo
7011 bronze badges
7011 bronze badges
1
You need a controller to save the values you change in inline-grid.
– aravind
Jul 29 at 7:34
But I can not change anything in my grid
– Tomalo
Jul 29 at 7:36
add a comment |
1
You need a controller to save the values you change in inline-grid.
– aravind
Jul 29 at 7:34
But I can not change anything in my grid
– Tomalo
Jul 29 at 7:36
1
1
You need a controller to save the values you change in inline-grid.
– aravind
Jul 29 at 7:34
You need a controller to save the values you change in inline-grid.
– aravind
Jul 29 at 7:34
But I can not change anything in my grid
– Tomalo
Jul 29 at 7:36
But I can not change anything in my grid
– Tomalo
Jul 29 at 7:36
add a comment |
2 Answers
2
active
oldest
votes
You can take the reference from CMS module of core Magneto. This is the reference link for that https://github.com/magento/magento2/blob/2.1/app/code/Magento/Cms/view/adminhtml/ui_component/cms_block_listing.xml
Like showing in this file you need to add editorConfig to configure inline edit and you also need to create controller.
<item name="editorConfig" xsi:type="array">
<item name="selectProvider" xsi:type="string">cms_block_listing.cms_block_listing.cms_block_columns.ids</item>
<item name="enabled" xsi:type="boolean">true</item>
<item name="indexField" xsi:type="string">block_id</item>
<item name="clientConfig" xsi:type="array">
<item name="saveUrl" xsi:type="url" path="cms/block/inlineEdit"/>
<item name="validateBeforeSave" xsi:type="boolean">false</item>
</item>
</item>
add a comment |
In your Ui_component.xml place this code make inline edit work.
<settings>
<editorConfig>
<param name="clientConfig" xsi:type="array">
<item name="saveUrl" xsi:type="url" path="route/controllerfolder/controller"/>
<item name="validateBeforeSave" xsi:type="boolean">false</item>
</param>
<param name="indexField" xsi:type="string">primary_field</param>
<param name="enabled" xsi:type="boolean">true</param>
<param name="selectProvider" xsi:type="string">test_mytesting_index.test_mytesting_index.test_mytesting_columns.ids</param>
</editorConfig>
<childDefaults>
<param name="fieldAction" xsi:type="array">
<item name="provider" xsi:type="string">test_mytesting_index.test_mytesting_index.test_mytesting_columns_editor</item>
<item name="target" xsi:type="string">startEdit</item>
<item name="params" xsi:type="array">
<item name="0" xsi:type="string">$ $.$data.rowIndex </item>
<item name="1" xsi:type="boolean">true</item>
</item>
</param>
</childDefaults>
</settings>
To show a column in Inline-edit, add below code
<column name="your_field">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="sorting" xsi:type="string">asc</item>
<item name="label" xsi:type="string" translate="true">Your Field Label</item>
<item name="editor" xsi:type="array">
<item name="editorType" xsi:type="string">text</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">false</item>
</item>
</item>
</item>
</argument>
</column>
Next you need to create a controller,route/controllerfolder/controller.
Vendor/Module/Controller/Area(frontend(or)Adminhtml)/controllerfolder/controller
<?php
namespace VendorModuleControllerAdminhtmlcontrollerfolder;
class controller extends MagentoBackendAppAction
protected $jsonFactory;
public function __construct(
MagentoBackendAppActionContext $context,
MagentoFrameworkControllerResultJsonFactory $jsonFactory
)
parent::__construct($context);
$this->jsonFactory = $jsonFactory;
public function execute()
/** @var MagentoFrameworkControllerResultJson $resultJson */
$resultJson = $this->jsonFactory->create();
$error = false;
$messages = [];
if ($this->getRequest()->getParam('isAjax'))
$postItems = $this->getRequest()->getParam('items', []);
if (!count($postItems))
$messages[] = __('Please correct the data sent.');
$error = true;
else
foreach (array_keys($postItems) as $entityId)
/** load your model to update the data */
$model = $this->_objectManager->create('VendorModuleModelYourModel')->load($entityId);
try
$model->setData(array_merge($model->getData(), $postItems[$entityId]));
$model->save();
catch (Exception $e)
$messages[] = "[Error:] $e->getMessage()";
$error = true;
return $resultJson->setData([
'messages' => $messages,
'error' => $error
]);
I hope this helps!!
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f283600%2finline-edit-grid-magento-2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can take the reference from CMS module of core Magneto. This is the reference link for that https://github.com/magento/magento2/blob/2.1/app/code/Magento/Cms/view/adminhtml/ui_component/cms_block_listing.xml
Like showing in this file you need to add editorConfig to configure inline edit and you also need to create controller.
<item name="editorConfig" xsi:type="array">
<item name="selectProvider" xsi:type="string">cms_block_listing.cms_block_listing.cms_block_columns.ids</item>
<item name="enabled" xsi:type="boolean">true</item>
<item name="indexField" xsi:type="string">block_id</item>
<item name="clientConfig" xsi:type="array">
<item name="saveUrl" xsi:type="url" path="cms/block/inlineEdit"/>
<item name="validateBeforeSave" xsi:type="boolean">false</item>
</item>
</item>
add a comment |
You can take the reference from CMS module of core Magneto. This is the reference link for that https://github.com/magento/magento2/blob/2.1/app/code/Magento/Cms/view/adminhtml/ui_component/cms_block_listing.xml
Like showing in this file you need to add editorConfig to configure inline edit and you also need to create controller.
<item name="editorConfig" xsi:type="array">
<item name="selectProvider" xsi:type="string">cms_block_listing.cms_block_listing.cms_block_columns.ids</item>
<item name="enabled" xsi:type="boolean">true</item>
<item name="indexField" xsi:type="string">block_id</item>
<item name="clientConfig" xsi:type="array">
<item name="saveUrl" xsi:type="url" path="cms/block/inlineEdit"/>
<item name="validateBeforeSave" xsi:type="boolean">false</item>
</item>
</item>
add a comment |
You can take the reference from CMS module of core Magneto. This is the reference link for that https://github.com/magento/magento2/blob/2.1/app/code/Magento/Cms/view/adminhtml/ui_component/cms_block_listing.xml
Like showing in this file you need to add editorConfig to configure inline edit and you also need to create controller.
<item name="editorConfig" xsi:type="array">
<item name="selectProvider" xsi:type="string">cms_block_listing.cms_block_listing.cms_block_columns.ids</item>
<item name="enabled" xsi:type="boolean">true</item>
<item name="indexField" xsi:type="string">block_id</item>
<item name="clientConfig" xsi:type="array">
<item name="saveUrl" xsi:type="url" path="cms/block/inlineEdit"/>
<item name="validateBeforeSave" xsi:type="boolean">false</item>
</item>
</item>
You can take the reference from CMS module of core Magneto. This is the reference link for that https://github.com/magento/magento2/blob/2.1/app/code/Magento/Cms/view/adminhtml/ui_component/cms_block_listing.xml
Like showing in this file you need to add editorConfig to configure inline edit and you also need to create controller.
<item name="editorConfig" xsi:type="array">
<item name="selectProvider" xsi:type="string">cms_block_listing.cms_block_listing.cms_block_columns.ids</item>
<item name="enabled" xsi:type="boolean">true</item>
<item name="indexField" xsi:type="string">block_id</item>
<item name="clientConfig" xsi:type="array">
<item name="saveUrl" xsi:type="url" path="cms/block/inlineEdit"/>
<item name="validateBeforeSave" xsi:type="boolean">false</item>
</item>
</item>
answered Jul 29 at 7:45
Gaurav KhatriGaurav Khatri
674 bronze badges
674 bronze badges
add a comment |
add a comment |
In your Ui_component.xml place this code make inline edit work.
<settings>
<editorConfig>
<param name="clientConfig" xsi:type="array">
<item name="saveUrl" xsi:type="url" path="route/controllerfolder/controller"/>
<item name="validateBeforeSave" xsi:type="boolean">false</item>
</param>
<param name="indexField" xsi:type="string">primary_field</param>
<param name="enabled" xsi:type="boolean">true</param>
<param name="selectProvider" xsi:type="string">test_mytesting_index.test_mytesting_index.test_mytesting_columns.ids</param>
</editorConfig>
<childDefaults>
<param name="fieldAction" xsi:type="array">
<item name="provider" xsi:type="string">test_mytesting_index.test_mytesting_index.test_mytesting_columns_editor</item>
<item name="target" xsi:type="string">startEdit</item>
<item name="params" xsi:type="array">
<item name="0" xsi:type="string">$ $.$data.rowIndex </item>
<item name="1" xsi:type="boolean">true</item>
</item>
</param>
</childDefaults>
</settings>
To show a column in Inline-edit, add below code
<column name="your_field">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="sorting" xsi:type="string">asc</item>
<item name="label" xsi:type="string" translate="true">Your Field Label</item>
<item name="editor" xsi:type="array">
<item name="editorType" xsi:type="string">text</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">false</item>
</item>
</item>
</item>
</argument>
</column>
Next you need to create a controller,route/controllerfolder/controller.
Vendor/Module/Controller/Area(frontend(or)Adminhtml)/controllerfolder/controller
<?php
namespace VendorModuleControllerAdminhtmlcontrollerfolder;
class controller extends MagentoBackendAppAction
protected $jsonFactory;
public function __construct(
MagentoBackendAppActionContext $context,
MagentoFrameworkControllerResultJsonFactory $jsonFactory
)
parent::__construct($context);
$this->jsonFactory = $jsonFactory;
public function execute()
/** @var MagentoFrameworkControllerResultJson $resultJson */
$resultJson = $this->jsonFactory->create();
$error = false;
$messages = [];
if ($this->getRequest()->getParam('isAjax'))
$postItems = $this->getRequest()->getParam('items', []);
if (!count($postItems))
$messages[] = __('Please correct the data sent.');
$error = true;
else
foreach (array_keys($postItems) as $entityId)
/** load your model to update the data */
$model = $this->_objectManager->create('VendorModuleModelYourModel')->load($entityId);
try
$model->setData(array_merge($model->getData(), $postItems[$entityId]));
$model->save();
catch (Exception $e)
$messages[] = "[Error:] $e->getMessage()";
$error = true;
return $resultJson->setData([
'messages' => $messages,
'error' => $error
]);
I hope this helps!!
add a comment |
In your Ui_component.xml place this code make inline edit work.
<settings>
<editorConfig>
<param name="clientConfig" xsi:type="array">
<item name="saveUrl" xsi:type="url" path="route/controllerfolder/controller"/>
<item name="validateBeforeSave" xsi:type="boolean">false</item>
</param>
<param name="indexField" xsi:type="string">primary_field</param>
<param name="enabled" xsi:type="boolean">true</param>
<param name="selectProvider" xsi:type="string">test_mytesting_index.test_mytesting_index.test_mytesting_columns.ids</param>
</editorConfig>
<childDefaults>
<param name="fieldAction" xsi:type="array">
<item name="provider" xsi:type="string">test_mytesting_index.test_mytesting_index.test_mytesting_columns_editor</item>
<item name="target" xsi:type="string">startEdit</item>
<item name="params" xsi:type="array">
<item name="0" xsi:type="string">$ $.$data.rowIndex </item>
<item name="1" xsi:type="boolean">true</item>
</item>
</param>
</childDefaults>
</settings>
To show a column in Inline-edit, add below code
<column name="your_field">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="sorting" xsi:type="string">asc</item>
<item name="label" xsi:type="string" translate="true">Your Field Label</item>
<item name="editor" xsi:type="array">
<item name="editorType" xsi:type="string">text</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">false</item>
</item>
</item>
</item>
</argument>
</column>
Next you need to create a controller,route/controllerfolder/controller.
Vendor/Module/Controller/Area(frontend(or)Adminhtml)/controllerfolder/controller
<?php
namespace VendorModuleControllerAdminhtmlcontrollerfolder;
class controller extends MagentoBackendAppAction
protected $jsonFactory;
public function __construct(
MagentoBackendAppActionContext $context,
MagentoFrameworkControllerResultJsonFactory $jsonFactory
)
parent::__construct($context);
$this->jsonFactory = $jsonFactory;
public function execute()
/** @var MagentoFrameworkControllerResultJson $resultJson */
$resultJson = $this->jsonFactory->create();
$error = false;
$messages = [];
if ($this->getRequest()->getParam('isAjax'))
$postItems = $this->getRequest()->getParam('items', []);
if (!count($postItems))
$messages[] = __('Please correct the data sent.');
$error = true;
else
foreach (array_keys($postItems) as $entityId)
/** load your model to update the data */
$model = $this->_objectManager->create('VendorModuleModelYourModel')->load($entityId);
try
$model->setData(array_merge($model->getData(), $postItems[$entityId]));
$model->save();
catch (Exception $e)
$messages[] = "[Error:] $e->getMessage()";
$error = true;
return $resultJson->setData([
'messages' => $messages,
'error' => $error
]);
I hope this helps!!
add a comment |
In your Ui_component.xml place this code make inline edit work.
<settings>
<editorConfig>
<param name="clientConfig" xsi:type="array">
<item name="saveUrl" xsi:type="url" path="route/controllerfolder/controller"/>
<item name="validateBeforeSave" xsi:type="boolean">false</item>
</param>
<param name="indexField" xsi:type="string">primary_field</param>
<param name="enabled" xsi:type="boolean">true</param>
<param name="selectProvider" xsi:type="string">test_mytesting_index.test_mytesting_index.test_mytesting_columns.ids</param>
</editorConfig>
<childDefaults>
<param name="fieldAction" xsi:type="array">
<item name="provider" xsi:type="string">test_mytesting_index.test_mytesting_index.test_mytesting_columns_editor</item>
<item name="target" xsi:type="string">startEdit</item>
<item name="params" xsi:type="array">
<item name="0" xsi:type="string">$ $.$data.rowIndex </item>
<item name="1" xsi:type="boolean">true</item>
</item>
</param>
</childDefaults>
</settings>
To show a column in Inline-edit, add below code
<column name="your_field">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="sorting" xsi:type="string">asc</item>
<item name="label" xsi:type="string" translate="true">Your Field Label</item>
<item name="editor" xsi:type="array">
<item name="editorType" xsi:type="string">text</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">false</item>
</item>
</item>
</item>
</argument>
</column>
Next you need to create a controller,route/controllerfolder/controller.
Vendor/Module/Controller/Area(frontend(or)Adminhtml)/controllerfolder/controller
<?php
namespace VendorModuleControllerAdminhtmlcontrollerfolder;
class controller extends MagentoBackendAppAction
protected $jsonFactory;
public function __construct(
MagentoBackendAppActionContext $context,
MagentoFrameworkControllerResultJsonFactory $jsonFactory
)
parent::__construct($context);
$this->jsonFactory = $jsonFactory;
public function execute()
/** @var MagentoFrameworkControllerResultJson $resultJson */
$resultJson = $this->jsonFactory->create();
$error = false;
$messages = [];
if ($this->getRequest()->getParam('isAjax'))
$postItems = $this->getRequest()->getParam('items', []);
if (!count($postItems))
$messages[] = __('Please correct the data sent.');
$error = true;
else
foreach (array_keys($postItems) as $entityId)
/** load your model to update the data */
$model = $this->_objectManager->create('VendorModuleModelYourModel')->load($entityId);
try
$model->setData(array_merge($model->getData(), $postItems[$entityId]));
$model->save();
catch (Exception $e)
$messages[] = "[Error:] $e->getMessage()";
$error = true;
return $resultJson->setData([
'messages' => $messages,
'error' => $error
]);
I hope this helps!!
In your Ui_component.xml place this code make inline edit work.
<settings>
<editorConfig>
<param name="clientConfig" xsi:type="array">
<item name="saveUrl" xsi:type="url" path="route/controllerfolder/controller"/>
<item name="validateBeforeSave" xsi:type="boolean">false</item>
</param>
<param name="indexField" xsi:type="string">primary_field</param>
<param name="enabled" xsi:type="boolean">true</param>
<param name="selectProvider" xsi:type="string">test_mytesting_index.test_mytesting_index.test_mytesting_columns.ids</param>
</editorConfig>
<childDefaults>
<param name="fieldAction" xsi:type="array">
<item name="provider" xsi:type="string">test_mytesting_index.test_mytesting_index.test_mytesting_columns_editor</item>
<item name="target" xsi:type="string">startEdit</item>
<item name="params" xsi:type="array">
<item name="0" xsi:type="string">$ $.$data.rowIndex </item>
<item name="1" xsi:type="boolean">true</item>
</item>
</param>
</childDefaults>
</settings>
To show a column in Inline-edit, add below code
<column name="your_field">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="sorting" xsi:type="string">asc</item>
<item name="label" xsi:type="string" translate="true">Your Field Label</item>
<item name="editor" xsi:type="array">
<item name="editorType" xsi:type="string">text</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">false</item>
</item>
</item>
</item>
</argument>
</column>
Next you need to create a controller,route/controllerfolder/controller.
Vendor/Module/Controller/Area(frontend(or)Adminhtml)/controllerfolder/controller
<?php
namespace VendorModuleControllerAdminhtmlcontrollerfolder;
class controller extends MagentoBackendAppAction
protected $jsonFactory;
public function __construct(
MagentoBackendAppActionContext $context,
MagentoFrameworkControllerResultJsonFactory $jsonFactory
)
parent::__construct($context);
$this->jsonFactory = $jsonFactory;
public function execute()
/** @var MagentoFrameworkControllerResultJson $resultJson */
$resultJson = $this->jsonFactory->create();
$error = false;
$messages = [];
if ($this->getRequest()->getParam('isAjax'))
$postItems = $this->getRequest()->getParam('items', []);
if (!count($postItems))
$messages[] = __('Please correct the data sent.');
$error = true;
else
foreach (array_keys($postItems) as $entityId)
/** load your model to update the data */
$model = $this->_objectManager->create('VendorModuleModelYourModel')->load($entityId);
try
$model->setData(array_merge($model->getData(), $postItems[$entityId]));
$model->save();
catch (Exception $e)
$messages[] = "[Error:] $e->getMessage()";
$error = true;
return $resultJson->setData([
'messages' => $messages,
'error' => $error
]);
I hope this helps!!
answered Jul 29 at 8:54
aravindaravind
6821 silver badge14 bronze badges
6821 silver badge14 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f283600%2finline-edit-grid-magento-2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
You need a controller to save the values you change in inline-grid.
– aravind
Jul 29 at 7:34
But I can not change anything in my grid
– Tomalo
Jul 29 at 7:36