Is there a way to filter FeatureTable by attribute? I found similiar question but for version 3.x and it requires to implement custom input field for each column.
Maybe version 4.x does support such functionality out of the box?
Solved! Go to Solution.
I created a widget to duplicate the functionalities of the filtering of the AT in WAB.
This is the main core of the widget. For the selected layer, I have a dropdown listing all fields and another dropdown for all values of the selected field where the user can create their SQLwhere statement. I hope it helps.
const getQuery = async (SQLwhere) => {
let thelayer = theselectedlayer;
let query = thelayer.createQuery();
query.where = SQLwhere;
let thevalues = [];
// query.orderByFields = selectedField;
query.outFields = ["*"];
query.returnDistinctValues = false;
query.returnGeometry = true;
thelayer
.queryFeatures(query)
.then((results) => {
console.log(results);
if (results.features.length === 0) {
document.getElementById("Message_html").innerHTML =
"Query returned no features.";
return;
}
if (featureTable) {
featureTable.selectRows(results.features);
}
I created a widget to duplicate the functionalities of the filtering of the AT in WAB.
This is the main core of the widget. For the selected layer, I have a dropdown listing all fields and another dropdown for all values of the selected field where the user can create their SQLwhere statement. I hope it helps.
const getQuery = async (SQLwhere) => {
let thelayer = theselectedlayer;
let query = thelayer.createQuery();
query.where = SQLwhere;
let thevalues = [];
// query.orderByFields = selectedField;
query.outFields = ["*"];
query.returnDistinctValues = false;
query.returnGeometry = true;
thelayer
.queryFeatures(query)
.then((results) => {
console.log(results);
if (results.features.length === 0) {
document.getElementById("Message_html").innerHTML =
"Query returned no features.";
return;
}
if (featureTable) {
featureTable.selectRows(results.features);
}