Damn, I spent so much time building this, I’m happy I could find the solution ! Here’s a dojo grid working with Zend framework. I fist tried this on the view controller, but it got me nowhere :

  1. // My function that is supposed to add the
  2. // OD column to ID, it never gets fired…
  3. <script type=”text/javascript”>
  4. function getODtoID()  {  alert(“test”);   }
  5. </script>
  6. /* My grid, it’s working except get=”getODtoID” */
  7. <table id=”grid” dojotype=”dojox.grid.Grid” store=”pStore” query=”{ post_id: ‘*’}”>
  8. <thead>
  9. <tr>
  10. <th field=”status” width=”30px”>Status</th>
  11. <th width=”5em” get=”getODtoID”>OD to ID</th>
  12. </tr>
  13. </thead>
  14. </table>
  15. dojo()->enable()
  16. ->setDjConfigOption(‘parseOnLoad’, true)
  17. ->requireModule(‘dojo.parser’)
  18. ->requireModule(‘dojo.data.ItemFileReadStore’)
  19. ->requireModule(‘dojox.grid.Grid’)
  20. ->requireModule(‘dojox.grid._data.model’);
  21. ?>

The problem was that I couldn’t get the function getODtoID to be executed. I wanted to build a link on my grid, and for that I needed some very basic calculation. So what’s the solution ? I still can’t figure out why it’s not working this way, but I tryied something else :

  1. <script type=”text/javascript”>
  2. var customColumn = function(inRowIndex) {
  3. // This is standard for many grid handlers
  4. if (! dijit.byId(‘grid’).model.data[inRowIndex]) {
  5. return;
  6. }
  7. return “<a href=\”/blogmanager/edit?id=” +
  8. model.getRow(inRowIndex).post_id + “\”>edit</a>”;
  9. }
  10. var view = {
  11. cells:  [[
  12. { name: “Post id”, field: “post_id” },
  13. { name: ‘Link’, get: customColumn }
  14. ],
  15. ]};
  16. var layout = [ view ];
  17. </script>
  18. <div dojotype=”dojox.grid.data.DojoData” jsid=”model” store=”pStore” query=”{ post_id: ‘*’ }” clientsort=”true”></div>
  19. <div id=”grid” dojotype=”dojox.Grid” model=”model” structure=”layout”></div>
  20. dojo()->enable()
  21. ->setDjConfigOption(‘parseOnLoad’, true)
  22. ->setDjConfigOption(‘isDebug’, true)
  23. ->requireModule(‘dojo.parser’)
  24. ->requireModule(‘dojo.data.ItemFileReadStore’)
  25. ->requireModule(‘dojox.grid.Grid’);
  26. ?>

And that’s working fine, fine fine. So now it’s easy to build custom cells withing your grids !