Select to view content in your preferred language

Selecting a feature for FeatureTable (js 4.24)

507
1
07-15-2022 01:15 PM
khanley
New Contributor II

So my potentially dumb question is really three potentially dumb questions, but they all have to do with the FeatureTable, so hopefully asking all three of them in the same place will be OK.

I have things set up properly, I believe, as I can click the Feature and the data will show up in the FeatureTable, but the Feature doesn't highlight, and it doesn't register as actually selecting it. (It shows, Features: 1, Selected: 0). The way I'm doing it is as follows:

       view.on("click", (evt) => {
        var mapPoint = evt.mapPoint;
        featureTable.filterGeometry = mapPoint;
     });
 
This takes the geometry from my MapPoint and makes the feature show up in the FeatureTable, but it doesn't show as Selected and it doesn't Highlight. I figured out that I can cheat by using 
featureTable.selectRows("0"), but it seems silly to do it this way since clearly it knows which feature I'm clicking when it filters it as the only feature in the table. I should also say that the Feature isn't actually added to the View, (as I am mostly using MapImageLayers for the actual visible Layers) but the Search widget seems to be  able to use the non-visible FeatureLayer and highlight it, so I would assume the FeatureTable can too.
 
So my questions are:
 
1) Does the layer have to be visible to highlight?
2) What am I missing in regards to having it register as "selecting"?
3) Is there a way to have the FeatureTable not load data upon first loading? I only want to use the FeatureTable to show what the user is selecting, so I don't need a list of all 109k features to begin with.
 
Thank you as always!
0 Kudos
1 Reply
Justin_Greco
Occasional Contributor III

#1 To highlight on the map, yes it does need to be visible.  Either that or add graphics to the map or to a graphics layer.

#2 featureTable.selectRows() will take either a number or a graphic, but you have "0" as a string try just featureTable.selectRows(0)

#3  There are two options that I have used:

a. You can set the definitionExpression for the feature layer for the table to something that is impossible, like OBJECTID IS NULL.  That should give you an empty table. 

b. Create an empty FeatureLayer in your app to use as the layer for the table, query the layer with 109k features and the use applyEdits to send them to the empty layer.  You would need to delete them as well using applyEdits when you add new data to it.

0 Kudos