|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
[Grid] dynamiccaly refreshing a grid using a new datastoreHi Dojo users
I'm trying to write a javascript framework. I'm playing with dojox grid, and I'm wonderinh how to dynamically set the model of a grid. I'm getting data from server by a xhrPost. This is the method I added to grid prototype : dojox.grid.Grid.prototype.fillData = function(objData,params){ params = params || {}; var store = new dojo.data.ItemFileReadStore({data:objData}); store.fetch(); this.setModel(store); } And here is my object declaration (html) : <table dojoType="dojox.grid.Grid" clientSort="true" query="{}" jsId="myGrid" > <THEAD> <TR> <TH width="80" sortable="true"> </TH> <TH field="libelle" width="*" >Menu</TH> <TH field="parent_name" width="*">Parent</TH> <TH>Default / First page</TH> <TH>Valid</TH> <TH class="button" width="80">Level</TH> <TH align="center" width="50"> </TH> </TR> </THEAD> </table> I'm working with dojo 1.1.1 (13707). I dynamically update my grid using : myGrid.fillData(data); data beeing an object containting items. "modulemenu.grid.model" give "Object _arrayOfAllItems=[9] _arrayOfTopLevelItems=[9]" but my grid doesn't show anyhting. I tried myGrid.model.refresh, but this doesn't work. Any idea to refresh the grid with the news model / store ? Thanks! -- David Wartel _______________________________________________ FAQ: http://dojotoolkit.org/support/faq Book: http://dojotoolkit.org/docs/book Forums: http://dojotoolkit.org/forum Dojo-interest@... http://turtle.dojotoolkit.org/mailman/listinfo/dojo-interest |
|
|
Re: [Grid] dynamiccaly refreshing a grid using a new datastoreThe model is not the datastore. A model is an instance of a model
class, such as dojox.grid.data.DojoData, which in turn has a reference to the datastore being used to construct the model. See: http://www.dojotoolkit.org/book/dojo-book-0-9-1-0/part-2-dijit-dojo-widget-library/advanced-editing-and-display/grid-1-0/sortin On constructing a new model. -- Jared On Sun, Jul 13, 2008 at 5:33 PM, David W. <mon.courriel@...> wrote: > Hi Dojo users > > I'm trying to write a javascript framework. > I'm playing with dojox grid, and I'm wonderinh how to dynamically set > the model of a grid. > I'm getting data from server by a xhrPost. > This is the method I added to grid prototype : > > dojox.grid.Grid.prototype.fillData = function(objData,params){ > params = params || {}; > var store = new dojo.data.ItemFileReadStore({data:objData}); > store.fetch(); > this.setModel(store); > } > > > And here is my object declaration (html) : > <table dojoType="dojox.grid.Grid" clientSort="true" > query="{}" jsId="myGrid" > > > <THEAD> > <TR> > <TH width="80" sortable="true"> </TH> > <TH field="libelle" width="*" >Menu</TH> > <TH field="parent_name" width="*">Parent</TH> > <TH>Default / First page</TH> > <TH>Valid</TH> > <TH class="button" width="80">Level</TH> > <TH align="center" width="50"> </TH> > </TR> > </THEAD> > > </table> > I'm working with dojo 1.1.1 (13707). > > > I dynamically update my grid using : > myGrid.fillData(data); > data beeing an object containting items. > > "modulemenu.grid.model" give "Object _arrayOfAllItems=[9] > _arrayOfTopLevelItems=[9]" but my grid doesn't show anyhting. > I tried myGrid.model.refresh, but this doesn't work. > > Any idea to refresh the grid with the news model / store ? > > Thanks! > -- > David Wartel > _______________________________________________ > FAQ: http://dojotoolkit.org/support/faq > Book: http://dojotoolkit.org/docs/book > Forums: http://dojotoolkit.org/forum > Dojo-interest@... > http://turtle.dojotoolkit.org/mailman/listinfo/dojo-interest > FAQ: http://dojotoolkit.org/support/faq Book: http://dojotoolkit.org/docs/book Forums: http://dojotoolkit.org/forum Dojo-interest@... http://turtle.dojotoolkit.org/mailman/listinfo/dojo-interest |
|
|
Re: [Grid] dynamiccaly refreshing a grid using a new datastoreHi Jared, and thank you for your answer.
> The model is not the datastore. > ... > See: > http://www.dojotoolkit.org/book/dojo-book-0-9-1-0/part-2-dijit-dojo-widget-library/advanced-editing-and-display/grid-1-0/sortin > You're absolutely right. But I tried the method described in the article you mentionned. Here is my new method: dojox.grid.Grid.prototype.fillData = function(objData,params){ this.data = objData; params = params || {}; var store = new dojo.data.ItemFileReadStore({data:objData}); store.fetch(); this.setModel(new dojox.grid.data.DojoData(null,null,{store:store,query: { namespace: '*' }})); } But, even with this method, my grid doesn't display the items of its store. For your information, here are some debugging information : ' modulemenu.grid.model' : Object observers=[1] fields=Object store=Object data=[0] 'myGrid.model.store' : Object _arrayOfAllItems=[9] _arrayOfTopLevelItems=[9] Any idea ? Thanks ! -- David Wartel _______________________________________________ FAQ: http://dojotoolkit.org/support/faq Book: http://dojotoolkit.org/docs/book Forums: http://dojotoolkit.org/forum Dojo-interest@... http://turtle.dojotoolkit.org/mailman/listinfo/dojo-interest |
|
|
Re: [Grid] dynamiccaly refreshing a grid using a new datastoreHi,
OK, it works now with this method: dojox.grid.Grid.prototype.fillData = function(objData,params){ params = params || {}; store = new dojo.data.ItemFileReadStore({data:objData}); store.fetch(); newModel = new dojox.grid.data.DojoData(null,null,{rowsPerPage: 20, store: store, query: {}, clientSort: true}); this.setModel(newModel); } Thanks for all. -- David Wartel _______________________________________________ FAQ: http://dojotoolkit.org/support/faq Book: http://dojotoolkit.org/docs/book Forums: http://dojotoolkit.org/forum Dojo-interest@... http://turtle.dojotoolkit.org/mailman/listinfo/dojo-interest |
| Free Forum Powered by Nabble | Forum Help |