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.
Solved! Go to Solution.
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(); // // } // },
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(); // // } // },
ok. Thanks.
Did you have any luck getting this opertional? Did you just uncomment the code?
I haven't got to it yet. I got distracted to other duties. Will let you know when I do so.
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.
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.
I currently use 2.0 and haven't downloaded 2.1 yet. I'll try it. Thanks Robert.