开发者

Dojo: create programatically a menu in an enhancedgrid

I'm trying to create programatically an EnahncedGrid with a menu. I've got the grid to work, but I've been unable to use the m开发者_如何学Pythonenu. It just not shows up. The code is as follows:

<script>
sMenu = new dijit.Menu({});
      sMenu.addChild(new dijit.MenuItem({
          label: "Delete Record",
          iconClass: "dijitEditorIcon dijitEditorIconCancel",
          onClick : function(){
              alert(1);
          }
      }));
sMenu.startup();


/**
 * El grid propiamente dicho
 */
var grid = new dojox.grid.EnhancedGrid({
 id: "grid_"+i,
 query: {
              idDocument: '*'
          },
          plugins: {
           nestedSorting: true,
           indirectSelection: true,
           menus: {rowMenu:sMenu}
          },
          onRowDblClick: openFile,
          structure: layout
      })
</script>

Any idea what I'm doing wrong?


I haven't used this myself, but I have two possible suggestions:

First, make sure you're dojo.require-ing "dojox.grid.enhanced.plugins.Menu" and are only instantiating the widgets within a dojo.addOnLoad or dojo.ready.

If you've already done that, the second thing I'd suggest is giving your menu an id, and passing that id to the rowMenu property of the menus object (in other words, pass a string, not the widget itself). Although, the way you're doing it seems like it should work, judging from the code.

You can see a test page with working menus here: http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/grid/tests/enhanced/test_enhanced_grid_menus.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜