JS callback for grid actionHow to change admin login template in Magento 1.5 or 1.6I created a custom module ,but getting error, not able to figure out what the error is about. How to get out of this error?Magento2 override admin js fileMagento 2.1: Do we need to do anything special for the controll action to accept HTTP Post with Json Payload?Magento 2.1 Create a filter in the product grid by new attributeForm is not displayed on panel admin Magento 2Grid action column custom callback with multiple params in magento2How to solve Front controller reached 100 router match iterations in magento2Magento 2.3 Can't view module's front end page output?How to hide particular admin form field(UI Component) based on the value of select field?
Pressure in giant ball of water floating in space
Why do we need a bootloader separate from our application program in microcontrollers?
Why do most airliners have underwing engines, while business jets have rear-mounted engines?
Will Jimmy fall off his platform?
How complicated can a finite double complex over a field be?
Does the sensor of a dslr count the number of photons that hits it?
How did Einstein know the speed of light was constant?
Wearing special clothes in public while in niddah- isn't this a lack of tznius?
Why do Martians have to wear space helmets?
Soda water first stored in refrigerator and then at room temperature
Can a USB hub be used to access a drive from two devices?
Taking advantage when HR forgets to communicate the rules
Machine Learning Golf: Multiplication
What is this airplane with small wings at different angles seen at Paphos Airport?
Is reasonable to assume that the 食 in 月食/日食 can be interpreted as the sun/moon being "eaten" during an eclipse?
Is it acceptable that I plot a time-series figure with years increasing from right to left?
My professor has told me he will be the corresponding author. Will it hurt my future career?
Shipped package arrived - didn't order, possible scam?
Why do airports remove/realign runways?
Any way to meet code with 40.7% or 40.44% conduit fill?
What was the significance of Spider-Man: Far From Home being an MCU Phase 3 film instead of a Phase 4 film?
How did the IEC decide to create kibibytes?
Examples of fluid (including air) being used to transmit digital data?
How to play a D major chord lower than the open E major chord on guitar?
JS callback for grid action
How to change admin login template in Magento 1.5 or 1.6I created a custom module ,but getting error, not able to figure out what the error is about. How to get out of this error?Magento2 override admin js fileMagento 2.1: Do we need to do anything special for the controll action to accept HTTP Post with Json Payload?Magento 2.1 Create a filter in the product grid by new attributeForm is not displayed on panel admin Magento 2Grid action column custom callback with multiple params in magento2How to solve Front controller reached 100 router match iterations in magento2Magento 2.3 Can't view module's front end page output?How to hide particular admin form field(UI Component) based on the value of select field?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I see I can use custom action handlers for adminhtml grid actions. This is DOM node for action link (HTML):
<a class="action-menu-item"
data-bind="attr: href: $action().href,
text: $action().label,
click: $col.getActionHandler($action())"
data-repeat-index="0"
href="http://.../index.php/admin/customer/index/edit/id/1/">Edit</a>
I have created additional action in adminhtml grid with callback data (PHP code):
$actions['alert'] = [
'label' => __('Alert'),
'callback' => 'function() alert("Action!")'
];
This action is converted into JSON and is loaded to the grid in this format, where "callback" property is a string (JSON):
"alert":
"label": "Alert",
"callback": "function() alert("Action!")"
This is Magento parser for action's props (module-ui/view/base/web/js/grid/columns/actions.js
). This parser process JSON data and should call action's callback in case of callback is object/array/function (see _getCallback
):
getActionHandler: function (action)
var index = action.index,
rowIndex = action.rowIndex;
if (this.isHandlerRequired(index, rowIndex))
return this.applyAction.bind(this, index, rowIndex);
,
applyAction: function (actionIndex, rowIndex)
debugger
var action = this.getAction(rowIndex, actionIndex),
callback = this._getCallback(action);
action.confirm ?
this._confirm(action, callback) :
callback();
return this;
,
_getCallback: function (action)
var args = [action.index, action.recordId, action],
callback = action.callback;
if (utils.isObject(callback))
args.unshift(callback.target);
callback = registry.async(callback.provider);
else if (_.isArray(callback))
return this._getCallbacks(action);
else if (!_.isFunction(callback))
callback = this.defaultCallback.bind(this);
return function ()
callback.apply(callback, args);
;
,
But callback
property is a string, so defaultCallback
is used.
How can I use my own action handler in adminhtml grid actions?
magento2 javascript adminhtml grid knockoutjs
add a comment |
I see I can use custom action handlers for adminhtml grid actions. This is DOM node for action link (HTML):
<a class="action-menu-item"
data-bind="attr: href: $action().href,
text: $action().label,
click: $col.getActionHandler($action())"
data-repeat-index="0"
href="http://.../index.php/admin/customer/index/edit/id/1/">Edit</a>
I have created additional action in adminhtml grid with callback data (PHP code):
$actions['alert'] = [
'label' => __('Alert'),
'callback' => 'function() alert("Action!")'
];
This action is converted into JSON and is loaded to the grid in this format, where "callback" property is a string (JSON):
"alert":
"label": "Alert",
"callback": "function() alert("Action!")"
This is Magento parser for action's props (module-ui/view/base/web/js/grid/columns/actions.js
). This parser process JSON data and should call action's callback in case of callback is object/array/function (see _getCallback
):
getActionHandler: function (action)
var index = action.index,
rowIndex = action.rowIndex;
if (this.isHandlerRequired(index, rowIndex))
return this.applyAction.bind(this, index, rowIndex);
,
applyAction: function (actionIndex, rowIndex)
debugger
var action = this.getAction(rowIndex, actionIndex),
callback = this._getCallback(action);
action.confirm ?
this._confirm(action, callback) :
callback();
return this;
,
_getCallback: function (action)
var args = [action.index, action.recordId, action],
callback = action.callback;
if (utils.isObject(callback))
args.unshift(callback.target);
callback = registry.async(callback.provider);
else if (_.isArray(callback))
return this._getCallbacks(action);
else if (!_.isFunction(callback))
callback = this.defaultCallback.bind(this);
return function ()
callback.apply(callback, args);
;
,
But callback
property is a string, so defaultCallback
is used.
How can I use my own action handler in adminhtml grid actions?
magento2 javascript adminhtml grid knockoutjs
did you got fix for you own issue ?
– Pradeep Kumar
Jul 24 '17 at 9:40
as I recall, I created own action handler: github.com/praxigento/mobi_mod_mage2_accounting/blob/master/src/…
– Alex Gusev
Jul 25 '17 at 8:20
add a comment |
I see I can use custom action handlers for adminhtml grid actions. This is DOM node for action link (HTML):
<a class="action-menu-item"
data-bind="attr: href: $action().href,
text: $action().label,
click: $col.getActionHandler($action())"
data-repeat-index="0"
href="http://.../index.php/admin/customer/index/edit/id/1/">Edit</a>
I have created additional action in adminhtml grid with callback data (PHP code):
$actions['alert'] = [
'label' => __('Alert'),
'callback' => 'function() alert("Action!")'
];
This action is converted into JSON and is loaded to the grid in this format, where "callback" property is a string (JSON):
"alert":
"label": "Alert",
"callback": "function() alert("Action!")"
This is Magento parser for action's props (module-ui/view/base/web/js/grid/columns/actions.js
). This parser process JSON data and should call action's callback in case of callback is object/array/function (see _getCallback
):
getActionHandler: function (action)
var index = action.index,
rowIndex = action.rowIndex;
if (this.isHandlerRequired(index, rowIndex))
return this.applyAction.bind(this, index, rowIndex);
,
applyAction: function (actionIndex, rowIndex)
debugger
var action = this.getAction(rowIndex, actionIndex),
callback = this._getCallback(action);
action.confirm ?
this._confirm(action, callback) :
callback();
return this;
,
_getCallback: function (action)
var args = [action.index, action.recordId, action],
callback = action.callback;
if (utils.isObject(callback))
args.unshift(callback.target);
callback = registry.async(callback.provider);
else if (_.isArray(callback))
return this._getCallbacks(action);
else if (!_.isFunction(callback))
callback = this.defaultCallback.bind(this);
return function ()
callback.apply(callback, args);
;
,
But callback
property is a string, so defaultCallback
is used.
How can I use my own action handler in adminhtml grid actions?
magento2 javascript adminhtml grid knockoutjs
I see I can use custom action handlers for adminhtml grid actions. This is DOM node for action link (HTML):
<a class="action-menu-item"
data-bind="attr: href: $action().href,
text: $action().label,
click: $col.getActionHandler($action())"
data-repeat-index="0"
href="http://.../index.php/admin/customer/index/edit/id/1/">Edit</a>
I have created additional action in adminhtml grid with callback data (PHP code):
$actions['alert'] = [
'label' => __('Alert'),
'callback' => 'function() alert("Action!")'
];
This action is converted into JSON and is loaded to the grid in this format, where "callback" property is a string (JSON):
"alert":
"label": "Alert",
"callback": "function() alert("Action!")"
This is Magento parser for action's props (module-ui/view/base/web/js/grid/columns/actions.js
). This parser process JSON data and should call action's callback in case of callback is object/array/function (see _getCallback
):
getActionHandler: function (action)
var index = action.index,
rowIndex = action.rowIndex;
if (this.isHandlerRequired(index, rowIndex))
return this.applyAction.bind(this, index, rowIndex);
,
applyAction: function (actionIndex, rowIndex)
debugger
var action = this.getAction(rowIndex, actionIndex),
callback = this._getCallback(action);
action.confirm ?
this._confirm(action, callback) :
callback();
return this;
,
_getCallback: function (action)
var args = [action.index, action.recordId, action],
callback = action.callback;
if (utils.isObject(callback))
args.unshift(callback.target);
callback = registry.async(callback.provider);
else if (_.isArray(callback))
return this._getCallbacks(action);
else if (!_.isFunction(callback))
callback = this.defaultCallback.bind(this);
return function ()
callback.apply(callback, args);
;
,
But callback
property is a string, so defaultCallback
is used.
How can I use my own action handler in adminhtml grid actions?
magento2 javascript adminhtml grid knockoutjs
magento2 javascript adminhtml grid knockoutjs
edited Feb 19 '18 at 19:36
Zachary Craig
17714 bronze badges
17714 bronze badges
asked Apr 26 '17 at 21:31
Alex GusevAlex Gusev
1,0741 gold badge10 silver badges29 bronze badges
1,0741 gold badge10 silver badges29 bronze badges
did you got fix for you own issue ?
– Pradeep Kumar
Jul 24 '17 at 9:40
as I recall, I created own action handler: github.com/praxigento/mobi_mod_mage2_accounting/blob/master/src/…
– Alex Gusev
Jul 25 '17 at 8:20
add a comment |
did you got fix for you own issue ?
– Pradeep Kumar
Jul 24 '17 at 9:40
as I recall, I created own action handler: github.com/praxigento/mobi_mod_mage2_accounting/blob/master/src/…
– Alex Gusev
Jul 25 '17 at 8:20
did you got fix for you own issue ?
– Pradeep Kumar
Jul 24 '17 at 9:40
did you got fix for you own issue ?
– Pradeep Kumar
Jul 24 '17 at 9:40
as I recall, I created own action handler: github.com/praxigento/mobi_mod_mage2_accounting/blob/master/src/…
– Alex Gusev
Jul 25 '17 at 8:20
as I recall, I created own action handler: github.com/praxigento/mobi_mod_mage2_accounting/blob/master/src/…
– Alex Gusev
Jul 25 '17 at 8:20
add a comment |
1 Answer
1
active
oldest
votes
Update mass-action action in the grid component xml as below:
<action name="add">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="confirm" xsi:type="array">
<item name="title" xsi:type="string" translate="true">Add Data</item>
<item name="message" xsi:type="string" translate="true">Add Data ?</item>
</item>
<item name="type" xsi:type="string">add</item>
<item name="label" xsi:type="string" translate="true">Add Data</item>
<item name="callback" xsi:type="array">
<item name="provider" xsi:type="string">my_form.my_form.field_data</item>
<item name="target" xsi:type="string">addData</item>
</item>
</item>
</argument>
</action>
Here, my_form.my_form.field_data is my form namespace and file name.
field_data is my text field.
Below is my field with custom js component:
<field name="field_data">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="visible" xsi:type="boolean">false</item>
<item name="component" xsi:type="string">My_Module/js/data</item>
<item name="dataType" xsi:type="string">text</item>
<item name="formElement" xsi:type="string">input</item>
<item name="source" xsi:type="string">my_form_form_data_source</item>
<item name="label" xsi:type="string" translate="true">Mass Action Data</item>
</item>
</argument>
</field>
data.js component file:
define([
'underscore',
'uiRegistry',
'Magento_Ui/js/form/element/abstract'
], function (_, uiRegistry, Abstract)
'use strict';return Abstract.extend(
addData: function (action, data) );
console.log(selections); // you mass action value.
);
);
You can use any component js to handle the callback. I used my field component js and saved the data in the form field.
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%2f171918%2fjs-callback-for-grid-action%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Update mass-action action in the grid component xml as below:
<action name="add">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="confirm" xsi:type="array">
<item name="title" xsi:type="string" translate="true">Add Data</item>
<item name="message" xsi:type="string" translate="true">Add Data ?</item>
</item>
<item name="type" xsi:type="string">add</item>
<item name="label" xsi:type="string" translate="true">Add Data</item>
<item name="callback" xsi:type="array">
<item name="provider" xsi:type="string">my_form.my_form.field_data</item>
<item name="target" xsi:type="string">addData</item>
</item>
</item>
</argument>
</action>
Here, my_form.my_form.field_data is my form namespace and file name.
field_data is my text field.
Below is my field with custom js component:
<field name="field_data">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="visible" xsi:type="boolean">false</item>
<item name="component" xsi:type="string">My_Module/js/data</item>
<item name="dataType" xsi:type="string">text</item>
<item name="formElement" xsi:type="string">input</item>
<item name="source" xsi:type="string">my_form_form_data_source</item>
<item name="label" xsi:type="string" translate="true">Mass Action Data</item>
</item>
</argument>
</field>
data.js component file:
define([
'underscore',
'uiRegistry',
'Magento_Ui/js/form/element/abstract'
], function (_, uiRegistry, Abstract)
'use strict';return Abstract.extend(
addData: function (action, data) );
console.log(selections); // you mass action value.
);
);
You can use any component js to handle the callback. I used my field component js and saved the data in the form field.
add a comment |
Update mass-action action in the grid component xml as below:
<action name="add">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="confirm" xsi:type="array">
<item name="title" xsi:type="string" translate="true">Add Data</item>
<item name="message" xsi:type="string" translate="true">Add Data ?</item>
</item>
<item name="type" xsi:type="string">add</item>
<item name="label" xsi:type="string" translate="true">Add Data</item>
<item name="callback" xsi:type="array">
<item name="provider" xsi:type="string">my_form.my_form.field_data</item>
<item name="target" xsi:type="string">addData</item>
</item>
</item>
</argument>
</action>
Here, my_form.my_form.field_data is my form namespace and file name.
field_data is my text field.
Below is my field with custom js component:
<field name="field_data">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="visible" xsi:type="boolean">false</item>
<item name="component" xsi:type="string">My_Module/js/data</item>
<item name="dataType" xsi:type="string">text</item>
<item name="formElement" xsi:type="string">input</item>
<item name="source" xsi:type="string">my_form_form_data_source</item>
<item name="label" xsi:type="string" translate="true">Mass Action Data</item>
</item>
</argument>
</field>
data.js component file:
define([
'underscore',
'uiRegistry',
'Magento_Ui/js/form/element/abstract'
], function (_, uiRegistry, Abstract)
'use strict';return Abstract.extend(
addData: function (action, data) );
console.log(selections); // you mass action value.
);
);
You can use any component js to handle the callback. I used my field component js and saved the data in the form field.
add a comment |
Update mass-action action in the grid component xml as below:
<action name="add">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="confirm" xsi:type="array">
<item name="title" xsi:type="string" translate="true">Add Data</item>
<item name="message" xsi:type="string" translate="true">Add Data ?</item>
</item>
<item name="type" xsi:type="string">add</item>
<item name="label" xsi:type="string" translate="true">Add Data</item>
<item name="callback" xsi:type="array">
<item name="provider" xsi:type="string">my_form.my_form.field_data</item>
<item name="target" xsi:type="string">addData</item>
</item>
</item>
</argument>
</action>
Here, my_form.my_form.field_data is my form namespace and file name.
field_data is my text field.
Below is my field with custom js component:
<field name="field_data">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="visible" xsi:type="boolean">false</item>
<item name="component" xsi:type="string">My_Module/js/data</item>
<item name="dataType" xsi:type="string">text</item>
<item name="formElement" xsi:type="string">input</item>
<item name="source" xsi:type="string">my_form_form_data_source</item>
<item name="label" xsi:type="string" translate="true">Mass Action Data</item>
</item>
</argument>
</field>
data.js component file:
define([
'underscore',
'uiRegistry',
'Magento_Ui/js/form/element/abstract'
], function (_, uiRegistry, Abstract)
'use strict';return Abstract.extend(
addData: function (action, data) );
console.log(selections); // you mass action value.
);
);
You can use any component js to handle the callback. I used my field component js and saved the data in the form field.
Update mass-action action in the grid component xml as below:
<action name="add">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="confirm" xsi:type="array">
<item name="title" xsi:type="string" translate="true">Add Data</item>
<item name="message" xsi:type="string" translate="true">Add Data ?</item>
</item>
<item name="type" xsi:type="string">add</item>
<item name="label" xsi:type="string" translate="true">Add Data</item>
<item name="callback" xsi:type="array">
<item name="provider" xsi:type="string">my_form.my_form.field_data</item>
<item name="target" xsi:type="string">addData</item>
</item>
</item>
</argument>
</action>
Here, my_form.my_form.field_data is my form namespace and file name.
field_data is my text field.
Below is my field with custom js component:
<field name="field_data">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="visible" xsi:type="boolean">false</item>
<item name="component" xsi:type="string">My_Module/js/data</item>
<item name="dataType" xsi:type="string">text</item>
<item name="formElement" xsi:type="string">input</item>
<item name="source" xsi:type="string">my_form_form_data_source</item>
<item name="label" xsi:type="string" translate="true">Mass Action Data</item>
</item>
</argument>
</field>
data.js component file:
define([
'underscore',
'uiRegistry',
'Magento_Ui/js/form/element/abstract'
], function (_, uiRegistry, Abstract)
'use strict';return Abstract.extend(
addData: function (action, data) );
console.log(selections); // you mass action value.
);
);
You can use any component js to handle the callback. I used my field component js and saved the data in the form field.
answered Aug 10 '18 at 12:31
Milind SinghMilind Singh
8002 silver badges15 bronze badges
8002 silver badges15 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%2f171918%2fjs-callback-for-grid-action%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
did you got fix for you own issue ?
– Pradeep Kumar
Jul 24 '17 at 9:40
as I recall, I created own action handler: github.com/praxigento/mobi_mod_mage2_accounting/blob/master/src/…
– Alex Gusev
Jul 25 '17 at 8:20