Select to view content in your preferred language

The event for Clicking a row of Grid Not fired

3227
8
Jump to solution
03-25-2021 06:49 AM
ShaningYu
Honored Contributor

In my App, I create a FeatureTable that works with a FeatureLayer.  When the FeatureTable displays the data and the FeatureLayer is drawn on the Map.  I need to fire an event on clicking a row of the Grid, and retrieve the record's cells values.  Below is the related code.  However, when I click a row, nothing happens.  What's wrong with my code?  Thanks if you can help. 

myTable = new mv.esriModules.FeatureTable({
layer: myFeatureLayer,
visibleElements: { selectionColumn: true },
fieldConfigs: _fieldsConfig,
container: document.getElementById("tableDiv")
items: [{
label: "Zoom to feature(s)",
iconClass: "esri-icon-zoom-in-magnifying-glass",
clickFunction: function (event) { //
debugger;
//zoomToSelectedFeatureTable();
//console.log("Need to build zoomToSelectedFeatureTable function");
}
}]
});

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

It looks like you're configuring the FeatureTable incorrectly. You left off the menuConfig property for the items

myTable = new mv.esriModules.FeatureTable({
  layer: myFeatureLayer,
  visibleElements: { selectionColumn: true },
  fieldConfigs: _fieldsConfig,
  container: document.getElementById("tableDiv"),
  menuConfig: {
    items: [{
      label: "Zoom to feature(s)",
      iconClass: "esri-icon-zoom-in-magnifying-glass",
      clickFunction: function (event) { //
        debugger;
        //zoomToSelectedFeatureTable();
        //console.log("Need to build zoomToSelectedFeatureTable function");
      }
    }]
  }
});

It would help if you use the Insert Code option when adding code.

View solution in original post

0 Kudos
8 Replies
KenBuja
MVP Esteemed Contributor

It looks like you're configuring the FeatureTable incorrectly. You left off the menuConfig property for the items

myTable = new mv.esriModules.FeatureTable({
  layer: myFeatureLayer,
  visibleElements: { selectionColumn: true },
  fieldConfigs: _fieldsConfig,
  container: document.getElementById("tableDiv"),
  menuConfig: {
    items: [{
      label: "Zoom to feature(s)",
      iconClass: "esri-icon-zoom-in-magnifying-glass",
      clickFunction: function (event) { //
        debugger;
        //zoomToSelectedFeatureTable();
        //console.log("Need to build zoomToSelectedFeatureTable function");
      }
    }]
  }
});

It would help if you use the Insert Code option when adding code.

0 Kudos
ShaningYu
Honored Contributor

Dear Ken:  Thanks for your response.  I used your code, but it still does not fire.  Is there something still missin?  Thanks again.

myTable = new mv.esriModules.FeatureTable({
 layer: myFeatureLayer, visibleElements: { selectionColumn: true },
 fieldConfigs: _fieldsConfig,
 container: document.getElementById("tableDiv"),
 menuConfig: {
  items: [{
   label: "Zoom to feature(s)",
   iconClass: "esri-icon-zoom-in-magnifying-glass",
   clickFunction: function (event) { //
    debugger;
    //zoomToSelectedFeatureTable(); 
   }
  }]
 }
});

0 Kudos
ShaningYu
Honored Contributor

Dear Ken:  For the code below

this.gridTbl = $('#tableDiv');         // the Grid container
this.gridTbl.click(function(e) {
  debugger;   }

if I click a row of the grid, the event fire.  Is it possible to retrieve the row's value through the 'e'?  Through debugging, I can see some expected values (but not all).  Thanks if you can help.
}

 

 

0 Kudos
KenBuja
MVP Esteemed Contributor

That will give you information about the cell of the table you click on, but I'm not seeing anything about the row itself. Here's how to get the text of the cell

console.log(e.target.innerText);
0 Kudos
KenBuja
MVP Esteemed Contributor

That code refers to the context menu that you didn't want from your other thread.

0 Kudos
ShaningYu
Honored Contributor

I did use

.esri-feature-table__menu .esri-button-menu{display:none;}

through e.target.innerHTML, I can retrieve only the cell's value.  What I can retrieve the row's value?  Thanks for your help.

0 Kudos
KenBuja
MVP Esteemed Contributor

I don't know if that's possible. The FeatureTable widget is lacking in a few things.

0 Kudos
KenBuja
MVP Esteemed Contributor

However, remember that you have the selection-changed event (from this discussion) you can use.

0 Kudos