Select to view content in your preferred language

Simple Batch Editor ExB

04-24-2023 05:41 AM
New Contributor II

Hello. I was tasked with developing a simpler "batch attribute editor" in Experience Builder, since it is not yet available publicly. Unlike the WAB batch editor, I do not need an editor as the project demands are to take the selected rows and run various CRUD queries. 

So the best example I found, and modified it with other examples. 

I used esri-loader to dynamically load the JS API inside ExB and added most of the widget code from the example, but I need to select the feature table as the entire logic is based on the table selection event.

function selectFeatures(geometry) {
          if (csvLayerView) {
            // 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
              .then((results) => {
                if (results.features.length === 0) {
                } 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
                  featureTable.filterGeometry = geometry;
                  // counter_atts.innerHTML = results.features.length;

Currently the script I'm using is still using Feature Table like in JS API, but I don't need to load the table dynamically, just use the one in the view. 

        // create a new instance of a FeatureTable
        const featureTable = new this.FeatureTable({
          view: this.state.jimuMapView.view,
          layer: this.csvLayer,
          highlightOnRowSelectEnabled: true,
          container: document.getElementById("featureTable")

 let features = [];

        // Listen for the table's selection-change event
        featureTable.on("selection-change", (changes) => {
          // if the feature is unselected then remove the objectId
          // of the removed feature from the features array
          changes.removed.forEach((item) => {
            const data = features.find((data) => {
              return data === item.objectId;
            if (data) {
              features.splice(features.indexOf(data), 1);
              // counter_atts.innerHTML = counter_atts_value-1;

          // If the selection is added, push all added selections to array
          changes.added.forEach((item) => {
            // counter_atts.innerHTML = counter_atts_value+1;

          // set excluded effect on the features that are not selected in the table
          csvLayerView.featureEffect = {
            filter: {
              objectIds: features
            excludedEffect: "blur(5px) grayscale(90%) opacity(40%)"

Just need to select the rows in the table when the sketchviewmodel draws the rectangle and gets the features. Afterwards I can run CRUD operations with the selected features. 

0 Replies