2

How do I get the reference to the JavaScript object representing a dgrid instance. Consider this code:

var MyGrid = var EntityList = declare("ui.MyGrid", [List, Pagination], { ... });
var grid = new MyGrid();
domConstruct.place(grid.domNode, container);
grid.startup();

It's easy enough to access grid here because it's created programmatically, but if it's created declaratively, as in:

<div id="grid" data-dojo-type="ui.MyGrid" data-dojo-props="...">
  • dojo.byId('grid') returns the DOM node.
  • dijit.byId('grid') returns undefined.
  • adding data-dojo-id apparently has no effect.

How do I get a reference to the the actual javascript object behind #grid?

1 Answer 1

6

Your grid needs to mixin the dgrid/extensions/DijitRegistry extension. Grids with this extension will register themselves with the dijit registry so you can use dijit.byId('grid').

See https://github.com/SitePen/dgrid/wiki/DijitRegistry for more information.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.