问题
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