attribute table - click on feature highlights a row.

3482
7
Jump to solution
12-22-2015 04:20 PM
LefterisKoumis
Occasional Contributor III

For the FeatureTable there is an easy way to click on feature on the map and it highlights the table row for the selected feature on the table.

simply use featuretable.enableLayerClick=true

on this example:

ArcGIS API for JavaScript Sandbox

just enter on line 104

myTable.enableLayerClick=true;

and any feature you click on the map, you can see the highlighted row.

Here is my question. The Attribute table that is used in wab, is not declared as FeatureTable. So, to get the highlighted row after you click a feature on map, you will have to compare the evt and the records on the grid, and once a match is made use grid.rows.setOverRow  Am I see it right?

Thank you.

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Lefteris,

   Yes you are correct the WAB Attribute table widget does not have a similar property so you would have to get the OID of the selected feature i the map and then search the widgets table store for that OID. Actually there are some functions for this that are commented out in the attribute table widget (why they are commented out I do not know).

      // onGraphicClick: function(index, event) {
      //   // if (!this.showing || index !== this.layersIndex) {
      //   //   return;
      //   // }
      //   // var id = event.graphic.attributes[this.layers[this.layersIndex].objectIdField] + "";
      //   // this.highlightRow(id);
      //   // this.selectFeatures("mapclick", [event.graphic]);
      // },

      // highlightRow: function(id) {
      //   // if (!this.showing) {
      //   //   return;
      //   // }
      //   // var store = this.grids[this.layersIndex].store;
      //   // var row = -1;
      //   // for (var i in store.index) {
      //   //   if (i === id) {
      //   //     row = store.index;
      //   //     break;
      //   //   }
      //   // }
      //   // if (row > -1) {
      //   //   var rowsPerPage = this.grids[this.layersIndex].get("rowsPerPage");
      //   //   var pages = parseInt(row / rowsPerPage, 10);
      //   //   pages++;

      //   //   this.grids[this.layersIndex].gotoPage(pages);
      //   //   this.grids[this.layersIndex].clearSelection();
      //   //   this.grids[this.layersIndex].select(id);
      //   //   this.resetButtonStatus();
      //   // }
      // },

View solution in original post

7 Replies
RobertScheitlin__GISP
MVP Emeritus

Lefteris,

   Yes you are correct the WAB Attribute table widget does not have a similar property so you would have to get the OID of the selected feature i the map and then search the widgets table store for that OID. Actually there are some functions for this that are commented out in the attribute table widget (why they are commented out I do not know).

      // onGraphicClick: function(index, event) {
      //   // if (!this.showing || index !== this.layersIndex) {
      //   //   return;
      //   // }
      //   // var id = event.graphic.attributes[this.layers[this.layersIndex].objectIdField] + "";
      //   // this.highlightRow(id);
      //   // this.selectFeatures("mapclick", [event.graphic]);
      // },

      // highlightRow: function(id) {
      //   // if (!this.showing) {
      //   //   return;
      //   // }
      //   // var store = this.grids[this.layersIndex].store;
      //   // var row = -1;
      //   // for (var i in store.index) {
      //   //   if (i === id) {
      //   //     row = store.index;
      //   //     break;
      //   //   }
      //   // }
      //   // if (row > -1) {
      //   //   var rowsPerPage = this.grids[this.layersIndex].get("rowsPerPage");
      //   //   var pages = parseInt(row / rowsPerPage, 10);
      //   //   pages++;

      //   //   this.grids[this.layersIndex].gotoPage(pages);
      //   //   this.grids[this.layersIndex].clearSelection();
      //   //   this.grids[this.layersIndex].select(id);
      //   //   this.resetButtonStatus();
      //   // }
      // },
LefterisKoumis
Occasional Contributor III

ok. Thanks.

0 Kudos
JohnMurner
New Contributor

Did you have any luck getting this opertional?  Did you just uncomment the code?

0 Kudos
LefterisKoumis
Occasional Contributor III

I haven't got to it yet. I got distracted to other duties. Will let you know when I do so.

0 Kudos
helenchu
Occasional Contributor II

Hi Robert,

I searched for those lines of code in WAB Attribute table widget but couldn't find them.  Are they no longer available in newer version ?  Thanks.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Helen,

  This code was for older versions of WAB. In WAB 2.1 each layer in the AT Widget automatically responds to a feature being selected by either using FeatureLayer.select or using the Selection widget.

helenchu
Occasional Contributor II

I currently use 2.0 and haven't downloaded 2.1 yet.  I'll try it.  Thanks Robert. 

0 Kudos