This is not an AJAX request/response callback question...
I am building a grid using Dojo 1.5. I am trying to dojo.connect
expand/contract buttons with a function. My problem is that the grid.startup()
method seems to take a while after being called before the actual DOM nodes are created, so when I call dojo.query
none of the DOM nodes I want to connect events and handlers to are present.
I have the grid being created inside an init()
method, which is called by dojo.addOnLoad()
. I have the connectExpandos()
method connected to init()
via dojo.connect("init", connectExpandos);
This executes fine, but I need to setTimeout()
within a while l开发者_如何转开发oop to wait for the grid.startup() to finish...
Anyone aware of a better way to do this? Perhaps a grid.startup()
callback I can hook onto?
Another suggestion... it looks like the "startup" function, which is implemented in DataGrid's super class, _Grid (http://svn.dojotoolkit.org/src/dojox/trunk/grid/Grid.js), calls a function called render, which i believe is what actually render's the contents of the Grid. Subsequently, it looks like render calls a method "postrender" after it has finished rendering. Perhaps you could connect your method to the "postrender" method instead of "startup".
dojo.connect(grid, "postrender", function(){connectExpandos()})
I think the callback you were looking for was _onFetchComplete
dojo.connect(grid,'_onFetchComplete',function(event){
alert("hello data is loaded")
});
I think you can just connect an event to grid startup method
dojo.connect(grid, "startup", function(){connectExpandos()})
You could try creating the widget programatically (assuming you are not already), then just call your method after you call startup() (It seems odd to call startup() manually, but the example it shows in the source comments show calling grid.startup() manually).
<script type="text/javascript">
var grid = new dojox.grid.EnhancedGrid({plugins : {nestedSorting: true, dnd: true, indirectSelection: true,
menus:{headerMenu:"headerMenuId", rowMenu:"rowMenuId", cellMenu:"cellMenuId",selectedRegionMenu:"selectedRegionMenuId"}},
... }, dojo.byId('gridDiv'));
grid.startup();
connectExpandos();
</script>
精彩评论