Accessing Object of Magento Admin Grid via Java-Script

若如初见. 提交于 2019-12-08 09:56:19

问题


I would like to access the JavaScript Object of the Magento Adminhtml Grid. I want to reload the Grid after my Dialog is closed an the Ajax-Request to the Controller has finished.

If i modify the grid.js this is easy to make. But i don't want to modify the grid.js of magento itself.

Any ideas how i can access that object?


回答1:


Late answer, but maybe it will help someone

If you setup the grid in Grid.php like this:

parent::__construct();
$this->setId('your_grid_id');
.
.
.

from javascript, grid object is

your_grid_idJsObject

in your case

your_grid_idJsObject.reload();



回答2:


You can update your layout by this

<action method="addJs"><script>somepath/somefile.js</script></action>

For example, I needed to add javascript to sales->order grid.

<adminhtml_sales_order_index>
   <reference name="head">
      <action method="addJs"><script>somepath/somefile.js</script></action>
   </reference>
</adminhtml_sales_order_index>

js/somepath/somefile.js - this is path for file. Hope this help.



来源:https://stackoverflow.com/questions/13648881/accessing-object-of-magento-admin-grid-via-java-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!