Select to view content in your preferred language

Selected rows in a FeatureTable

1083
4
11-12-2020 02:29 PM
KenBuja
MVP Esteemed Contributor

There doesn't seem to be a way of getting the selected rows easily from a FeatureTable (v 4.17). The 3.x version has the selectedRows property...am I missing something? Currently, I am using the selection-change event to write the added and removed property arrays to a separate array

    featureTable.on('selection-change', (event) => {
      if (event.added.length > 0) filterArray.push(event.added[0].feature.attributes[valueString]);
      if (event.removed.length === 1) {
        const i = filterArray.indexOf(event.removed[0].feature.attributes[valueString]);
        filterArray.splice(i, 1);
      } else if (event.removed.length > 0) {
        filterArray = [];
      }
    });

 

Tags (1)
4 Replies
KavishGhime3
Emerging Contributor

Hello @KenBuja 

In the 4.x API reference, I cannot see the equivalent property of "selectedRows" which returns the name-value pair object in 3.x API.

In API 4.x, FeatureTable is still in Beta and new capabilities will be added in upcoming releases. For a more comprehensive list of limitations, please refer to the widget's API Reference documentation.

Thanks,

MichaelKarikari1
Occasional Contributor

I still don't see selectedRows as API option. Is it safe to say it is still not available yet and the poster except is the best option for now?

ZachPorteous
Emerging Contributor

That would be a great feature!!

0 Kudos
MichaelCollinsGIS
Emerging Contributor

I had wondered about this as well, and it seems the accepted way to do it is to instantiate a global variable, then modify it using the data from the change event. This works fine (albeit a little clumsy), and there is a good example of it here: Sandbox | Sample Code | ArcGIS API for JavaScript 4.24 | ArcGIS Developers

0 Kudos