enhancedgrid not updating

622
2
02-26-2013 12:29 PM
aubinmaynard
New Contributor
I've modified the find sample to use the enhanced dojo grid.  The first find task works fine, but any following will update the map but NOT the table.  I've included my showresults function which does the legwork for the table.  Examining firebug shows indicates there's something up with the store, but i just cannot seem to figure out how to clear it.  Thanks for you help in advance.

function showResults(results) {
    
     //symbology for graphics
        var markerSymbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE, 10, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255, 0, 0]), 1), new dojo.Color([0, 255, 0, 0.25]));
        var lineSymbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASH, new dojo.Color([255, 0, 0]), 1);
        var polygonSymbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_NONE, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASHDOT, new dojo.Color([255, 0, 0]), 2), new dojo.Color([255, 255, 0, 0.25]));

        //find results return an array of findResult.
        map.graphics.clear();
        var items = [];
  // close store, this should clear data
        //Build an array of attribute information and add each found graphic to the map
        dojo.forEach(results, function(result) {
   
    var graphic = result.feature;
          items.push([result.layerName, result.foundFieldName, result.value]);
          switch (graphic.geometry.type) {
          case "point":
            graphic.setSymbol(markerSymbol);
            break;
          case "polyline":
            graphic.setSymbol(lineSymbol);
            break;
          case "polygon":
            graphic.setSymbol(polygonSymbol);
            break;
          }
          map.graphics.add(graphic);
     return result.feature.attributes;
        });
          var data = {
          items: items
        };
       console.log(data)

     var store = new dojo.data.ItemFileWriteStore({clearOnClose: true, data: data
        });
     console.log(store)

  /*set up layout*/
var layout = [[
      {'name': 'Column 1', 'field': '0'},
      
    ]];

  /*create a new grid:*/
    var grid = new dojox.grid.EnhancedGrid({
  id: 'grid',
        store: store,
        structure: layout,
        rowSelector: '20px',
  plugins: {
            exporter: true}},
      document.createElement('div'));

    /*append the new grid to the div*/
    dojo.byId("grid").appendChild(grid.domNode);

   

    grid.startup();
0 Kudos
2 Replies
TimCollyer
Occasional Contributor
Try destroying any existing instance of the grid?

e.g. Before this line:

var grid = new dojox.grid.EnhancedGrid...

Try something like

if (dojo.byId("grid" )) dojo.byId("grid").destroy();
0 Kudos
aubinmaynard
New Contributor
No go yet.  Your suggestion just seems to popuplate a empty grid all the time.   I"ve been playing with grid.store.close();, but cannot seem to load any data into the grid on the second load.  An other suggestions.

Thanks,

Aubin
Try destroying any existing instance of the grid?

e.g. Before this line:

var grid = new dojox.grid.EnhancedGrid...

Try something like

if (dojo.byId("grid" )) dojo.byId("grid").destroy();
0 Kudos