Login Register

Updating the grid when the server-side data changes.

Hi there,

I'm using a grid that sources it's data from the server side using the custom model defined in the talk section of the docs for "Sorting and Other Dojo.Data Considerations" (see the declaration for "xyz.data.ServerGridData").

It works very nicely except when the data on the server side changes - e.g. when I use the grid to display results of a search. Something like:

dojo.xhrPost({
    url: '/doquery',
    form: queryform,
    onLoad: function() {
        dijit.byId('resultsgrid').refresh();
    }
})

If you change the query, it keeps the old data there and doesn't bother reloading new data (but alters the rowcount properly)

Am I calling the right thing to do the update? Is there some means by which I can force it to drop it's data and reload?

Thanks in advance,

Andy.

There have been several

There have been several posts on this subject in the forums here, which Search should find.

If you are using the QueryReadStore, this may help:

http://www.dojotoolkit.org/forum/dijit-dijit-0-9/dijit-development-discu...

http://www.dojotoolkit.org/forum/dojox-dojox/dojox-support/refresh-grid-...

For the ItemFileXXXXStore, IIRC, you restate the store, the model, and then grid.setModel(model);grid.refresh();

http://dojotoolkit.org/forum/dojox-dojox/dojox-grid-support/update-grid-...

Thanks for the quick

Thanks for the quick response, I was sure I'd tried all of these solutions but none of these worked.

However when I tried knocking up a quick page that did all of what I was trying to do (Grid loaded into a TabContainer using server-side data from QueryReadStore) it worked perfectly*. So the problem lies elsewhere. I need to think more about this.

But thanks again.

*If you or anyone else is curious, this is basically what I'm doing;

http://www.triv.org.uk/~nelis/g/test.html

And the source for data.php is:

http://www.triv.org.uk/~nelis/g/data_php_src.txt

(You'll need cookies enabled for this domain)

Solution

Well it turned out that my server-side data source was doing silly things - Grid.refresh() works fine.

But additionally in the xyz.data.ServerGridData class I mentioned (link to source above), there's a commented out line like this:

//onBegin: dojo.hitch(this, "beginReturn"),

This needs uncommenting, otherwise the grid won't clear rows properly.