Is it possible to query server-side FeatureTable without re-creating FeatureLayer?
Solved! Go to Solution.
I got a solution:
1. Create FeatureLayer:
let featureLayer= new FeatureLayer({
You can bring it in as a FeatureLayer and query it the same as you would as a feature layer.
const bldPermLayer = new FeatureLayer({
url: "https://.../server/rest/services/...",
outFields:["*"]
});
const featureTable = new FeatureTable({
view: theView,
layer: bldPermLayer,
});
function handleQueryResults() {
let queryBP = bldPermLayer.createQuery();
queryBP.where = "query"
queryBP.outFields = ["*"];
// do the query
bldPermLayer
.queryFeatures(queryBP)
.then((response) => {
// code
});
}
Thank you for your help!
Is it possible that FeatureTable get updated automatically when querying FeatureLayer?
What do you mean? Are trying to edit a FeatureTable through a query?
function handleQueryResults() { let queryBP = bldPermLayer.createQuery(); queryBP.where = "query" queryBP.outFields = ["*"]; // do the query bldPermLayer .queryFeatures(queryBP) .then((response) => { // code }); }
The response is FeatureSet, right? How to update FeatureTable using the response? Or FeatureTable got updated already?
Thanks.
Forrest
Do what you want with it in the code. It's the same data so it could go something like below.
function handleQueryResults() {
let queryBP = bldPermLayer.createQuery();
queryBP.where = "query"
queryBP.outFields = ["*"];
// do the query
bldPermLayer
.queryFeatures(queryBP)
.then((response) => {
featureTable.selectRows(response.features);
featureTable.filterBySelection();
});
}
Thank you so much for your help!
The total number of features in my FeatureLayer is about 500,000. I just need to get/query/search about 20 features each time, and then show them in the FeatureTable.
I don't want to create a new FeatureLayer and add to map each time I query. What should I do?
Forrest
You don't need to create a new FeatureLayer each time, just query off the one every time. In fact you don't need to add the FeatureLayer to the map at all. You might need to loop through the response.features, but not sure that is necessary.
I'm not sure how to update FeatureTable using the response.features.
These are just for selection of FeatureTable , not updating FeatureTable :
featureTable.selectRows(response.features);
featureTable.filterBySelection();
I got a solution:
1. Create FeatureLayer:
let featureLayer= new FeatureLayer({