How to get the list of selected rows from Feature Table without using the "selection-change" event of FeatureTable? Is there any straight method or way to get the selected rows?
Ranga,
Everytime the table's 'selection-change' event is fired it provides a list of rows added or removed from the selection. So after you set up the FeatureTable, set up a watch on that event such as:
// Get the FeatureLayer's layerView and listen for the table's selection-change event // Here I'm maintaining a list of features for use elsewhere let lstFeatures = []; aFTable.on("selection-change", function (changes) { var idxItem = 1; // If the selection is removed, remove the feature from the array changes.removed.forEach(function (item) { const data = lstFeatures.find(function (data) { return data.feature === item.feature; }); if (data) { lstFeatures.splice(lstFeatures.indexOf(data), 1); } }); // If the selection is added, push all added selections to array changes.added.forEach(function (item) { const feature = item.feature; lstFeatures.push({ feature: feature }); }); zoomToSelectedFeature(aLayer, lstFeatures, aView); });
HeatherGonzago I got enlighten, highly appreciated. Fully agree with you.
The property is hidden for a reason. You can use it if it works for now, but there is no guarantee that it won't be changed later on. We provided the event to get to the records so that you don't have to do this. I don't know the reasoning for not using this. Perhaps there is a use case that wasn't considered that needs to be, otherwise I would suggest the event as there is no support for undocumented properties, nor a guarantee that they won't change in any upcoming release.
Just noticed this hidden property of FeatureTable. Hope it is okay to rely on this to get the selected rows of FeatureTable.
FeatureTable.grid.selectedItems.items
JeffreyWilkerso Thank you for the response, appreciated.
However, as mentioned, I am looking out for a solution without using the "selection-change" event of FeatureTable?
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.