Dynamically refresh grid data

View: New views
1 Messages — Rating Filter:   Alert me  

Dynamically refresh grid data

by David W.-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

'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 new model / store ?

Thanks!
--
David Wartel

--
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
LightInTheBox - Buy quality products at wholesale price!