Select to view content in your preferred language

dojox.grid.DataGrid - how to clear results

6689
2
09-09-2011 02:17 AM
simonmiles
Emerging Contributor
I'm after help how to write a bit of JS that will clear both map graphics and a dojo datagrid on an onclick map event.

I know that the syntax for clearing a map graphic is - map.graphics.clear(); but i dont or cant find how to clear the search results showing in a datagrid; and if indeed it is possible to clear a datagrid, how i structure the JS to add the two bits of code together in a onclick, show a popup infowindow function event.

Alternatively and probably the better soultion. After doing a search via a grid.datagrid function and zooming to my feature; how to write an onclick event to show an infowindow, but remove all the map graphics but in doing the map.graphic.clear not disconnecting the results in the datagrid, so that I can continue to select a result and zoom off to it. As its stands, if i add a map.graphic.clear to my function that does the popup infowindow, it clears all the map graphics from my search, however the search results remain in the datagrid but dont zoom off to the feature anymore.

Anyhow, any help would be great.

Thanks in advance

Simon
0 Kudos
2 Replies
SiqiLi
by Esri Contributor
Esri Contributor
Use the following solution to clear the DataGrid. Basically, create a new empty store for the grid.

  
 var newStore = new dojo.data.ItemFileReadStore({data: {  identifier: "",  items: []}});
    var grid = dijit.byId("grid");
    grid.setStore(newStore);
 }
0 Kudos
BenjaminZank1
Deactivated User
Shuping,
Thank you so much for this post! I have been trying to figure out how to do this for weeks and this works perfectly.
Thanks again,
Ben
0 Kudos