views:

71

answers:

1

I have created a Dojo Grid that returns results from a .Net WS based on search criteria from the browser. The grid works fine the first it is populated, but if I make another search attempt. It throws the following error

Tried to register widget with id==grid but that id is already registered

I understand what the error means, it means that the ID has already been built and cannot be built again, but I have no idea how to fix it. Here is my JS Code

var grid = new dojox.grid.DataGrid({ autoWidth: "true", structure: gridLayout, store: store, clientSort: true }, "grid");

The HTML

What do I need to to the last property of the grid (ie the "grid" part) to make this error go away. Thanks in advance for any help.

A: 

One option would be to reuse the widget but replace its data via dojox.grid.DataGrid.setStore(). Related answer here.

kschneid
Currently I am using store = new dojox.data.ServiceStore({ service: service.serviceName });to create my store, and use grid.setQuery to fill my grid with my service object. Are there other options that fit more with my structure?
Isaac Levin
@kschneid is right—you should simply be changing the data in the store. You don't want to re-initialize the DataGrid each time you load the data.
Kyle Hayes
I am confused. What should I be doing to just repopulate the store instead of restarting the Grid.
Isaac Levin