AnsweredAssumed Answered

How do I select multiple rows from my dGrid?

Question asked by schlot on Sep 2, 2014
Latest reply on Sep 4, 2014 by schlot

I'm having a hard time managing my selected rows in my dGrid.  I read that the default selection mode is already set to extended. I have an event on dgrid-select that fire my chart function and that works.  I'd to be able to select mutiple rows from the grid to generate a chart with the information from multiple rows, but I'm having a hard time managing the selection.  As soon as I select one row, my chart gets generated.


I am creating my grid based on a featureLayer,queryFeatures.  Here's the result handler.

function gridHandler(results) {
  var rateTest, countTest;
  var returnObj = {};
    var gridColumns = buildColumns();

    var data =, function(feature){     
      return feature.attributes;

  grid = new (declare([Grid, Selection]))({
        columns: gridColumns
        }, "gridDiv"); 

     grid.on("dgrid-select", function(event){
        var rows = event.rows;
        var row = event.rows[0];
        var gridQuery = new Query();                                          
        gridQuery.objectIds = [];
        featureLayer.selectFeatures(gridQuery, FeatureLayer.SELECTION_NEW, function(results) {
          if ( results.length > 0 ) {
           // createLineChart(results);
            var feature = results[0];
            var resultGeometry = results[0].geometry; 
      //;      //assume geometry is a polygon      
          } else {
            console.log("error in grid.on click function");
    dom.byId("gridText").innerHTML = title+ " - " + currentYear;
//creates a column definition for the grid based on the attributes returned from the query
  function buildColumns() {
       var columns = [];
 //qryOutFields is an array of fieldNames defined earlier
    arrayUtils.forEach(qryOutFields, function(field){
            var objects = {};
            objects.label = field;
            objects.field = field;
            if (field === 'OBJECTID') {//assumed name for internal ID from map service
                objects.hidden = true;
    return columns;