FeatureTable with editing enabled

This sample demonstrates how to edit using the FeatureTable widget. In this example, editable data is enabled for editing within the widget. In order to enable this, the table's editingEnabled property must be set to true. Once set, the cell values within the table can be updated via a double-click.

Note that the service hosting the data must be enabled to allow editing. In this particular example, full editing privileges are granted on the data. It is also possible to restrict edit functionality even further at the field level. This is done by setting the table's fieldConfig.editable property to true within the table's field configurations. In this sample, the Case No. field is restricted to not allow editing.

In addition to showing tabular editing, this sample also demonstrates how to add sorting on multiple columns by setting multiSortEnabled to true.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
view.when(() => {
  // Create the feature layer
  featureLayer = new FeatureLayer({
    portalItem: {
      id: "3807c58dd48c4d32810042d8edf4a2fe"
    },
    outFields: ["*"],
    title: "Chicago crime incidents"
  });
  map.add(featureLayer);

// Create the feature table
const featureTable = new FeatureTable({
  view: view, // This must be set to enable highlight in the map
  layer: featureLayer,
  multiSortEnabled: true, // Set this to enable sorting on multiple columns
  editingEnabled: true, // This must be set to enable editing in the table
  tableTemplate: { // autocast to TableTemplate
    columnTemplates: [ // takes an array of GroupColumnTemplate and FieldColumnTemplate
    { // autocast to GroupColumnTemplate
      type: "group",
      label: "Crime details",
      columnTemplates: [
      {
        type: "field",
        fieldName: "Primary_Type",
        label: "Crime type"
      },
      {
        type: "field",
        fieldName: "Description",
        label: "Description"
      },
      {
        type: "field",
        fieldName: "Location_Description",
        label: "Location description"
      }]
    },
    {
      type: "group",
      label: "Arrest information",
      columnTemplates: [
      {
        type: "field",
        fieldName: "Arrest",
        label: "Arrest"
      },
      {
        type: "field",
        fieldName: "incident_date",
        label: "Date of incident"
      },
      {
        type: "field",
        fieldName: "Case_Number",
        label: "Case No.",
        editable: false
      }]
    }]
  },
  container: document.getElementById("tableDiv")
});
...

Known Limitations

For a comprehensive list of limitations, please refer to the widget's API Reference documentation.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.