Select to view content in your preferred language

Display only selected records on feature table.

1233
3
Jump to solution
08-17-2022 10:26 AM
LefterisKoumis
Frequent Contributor

I followed the script to display only the selected records on the feature table after you select by geometry as it is shown at:

https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=highlight-features-by-ge...

However, the featuretable does not filter out the unselected records.

 

function selectFeatures(geometry) {
  if (featureLayerView) {
    // create a query and set its geometry parameter to the
    // rectangle that was drawn on the view
    const query = {
      geometry: geometry,
      outFields: ["*"]
    };

    // query graphics from the csv layer view. Geometry set for the query
    // can be polygon for point features and only intersecting geometries are returned
    featureLayerView
      .queryFeatures(query)
      .then((results) => {
        const graphics = results.features;
        resultFeatures = graphics;
        if (results.features.length === 0) {
          clearSelection();
        } else {
          // pass in the query results to the table by calling its selectRows method.
          // This will trigger FeatureTable's selection-change event
          // where we will be setting the feature effect on the csv layer view
          console.log(featureTable)
          featureTable.filterGeometry = geometry;
          featureTable.selectRows(results.features);        
        }
      })
      .catch(errorCallback);
  }
}

 

 

LefterisKoumis_0-1660756921630.png

 

0 Kudos
1 Solution

Accepted Solutions
ReneRubalcava
Honored Contributor

Ok, I think I know what's happening with the polygons. I think what is happening here, is since the sample shows using the FeatureLayerView, it only queries data that has been downloaded and visible on the map, which makes sense.

However, if a polygon (or a polyline) is smaller than a pixel, as in, you couldn't see it anyway, it won't technically be in the LayerView since it's not drawn due to quantization in the request. This doesn't happen with points, because a point can always fit in a pixel.

If you update your demo to use fLayer.queryFeatures(query) it should work, and properly filter the table. 

View solution in original post

0 Kudos
3 Replies
ReneRubalcava
Honored Contributor

Can you provide a repro in codepen or something? Not sure what is different in your app versus the working sample.

0 Kudos
LefterisKoumis
Frequent Contributor

It seems it occurs when you don't use a point layer. Why?

I modified the sample code from esri and I have two layers. If set the point layer active (#74), upon selection by geometry the feature table shows only the selected features. However, if you set the polygon layer active (#72 the feature table still shows all records.

https://codepen.io/lkoumis1/pen/RwMEGBq?editors=1001

0 Kudos
ReneRubalcava
Honored Contributor

Ok, I think I know what's happening with the polygons. I think what is happening here, is since the sample shows using the FeatureLayerView, it only queries data that has been downloaded and visible on the map, which makes sense.

However, if a polygon (or a polyline) is smaller than a pixel, as in, you couldn't see it anyway, it won't technically be in the LayerView since it's not drawn due to quantization in the request. This doesn't happen with points, because a point can always fit in a pixel.

If you update your demo to use fLayer.queryFeatures(query) it should work, and properly filter the table. 

0 Kudos