featuretable

2081
2
10-30-2015 12:04 PM
BC
by
New Contributor II

I am exploring this as starting point for my application.

Using FeatureTable (no map) | ArcGIS API for JavaScript

How can I access a row/record selected?  Examples, I have seen examples refer to evt[0].data.Cmn_Name.  I am lost on how do you set up or access data object.

Thank you

Tags (1)
0 Kudos
2 Replies
KenBuja
MVP Esteemed Contributor

The FeatureTable has a dgrid-select event you can use to get information about the rows you've selected. The event will give you the array of rows you've selected and you can get information about the attributes of that row.

This example will return the attribute NAME for all selected rows.

<!DOCTYPE html>
<html>

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>FeatureTable without map</title>
  <link rel="stylesheet" href="https://community.esri.com//js.arcgis.com/3.14/dijit/themes/claro/claro.css">
  <link rel="stylesheet" href="https://community.esri.com//js.arcgis.com/3.14/esri/css/esri.css">
  <script src="//js.arcgis.com/3.14/"></script>

  <style>
    html, body, #map{
      width:100%;
      height:100%;
      margin:0;
      padding:0;
    }
  </style>

  <script>
    var map;

    require([
      "esri/IdentityManager",
      "esri/layers/FeatureLayer",
      "esri/dijit/FeatureTable",
      "dojo/dom-construct",
      "dojo/dom",
      "dojo/parser",
      "dojo/ready",
      "dojo/on",
      "dojo/_base/lang",
      "dijit/registry"
    ], function (
      IdentityManager, FeatureLayer, FeatureTable,
      domConstruct, dom, parser, ready, on,lang,
      registry
    ) {

      parser.parse();

      ready(function(){

          // Create the feature layer
        var myFeatureLayer = new FeatureLayer("http://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/california_census_blocks/FeatureSer...", {
          mode: FeatureLayer.MODE_ONDEMAND,
          outFields:  ["NAME","GEOID","MTFCC","ALAND","AWATER"],
          visible: true,
          id: "fLayer"
        });
        myTable = new FeatureTable({
          "featureLayer" : myFeatureLayer,
          "hiddenFields": ["FID","C_Seq","Street"]  // field that end-user can show, but is hidden on startup
        }, 'myTableNode');
        myTable.startup();
        myTable.on("dgrid-select", test);
        
        function test(evt){
          for(var i = 0; i < evt.length; i++){
            console.log (evt.data.NAME);
          }
        }
      });
    });
  </script>
</head>

<body class="claro esri">
  <p>
    <i>The FeatureTable dijit supports tables with lots of features, with the table growing as you scroll.</i>
  </p>
  <div id="myTableNode"></div>
</body>

</html>
DairisTapanes_Rios
New Contributor

Hi,

I'm using Featuretable(no map) .

when I select a row I bind a form using dgrid-select

myTable.on("row-select", function (evt) {

console.log("select event - ", evt.rows[0].data);
var Object = evt.rows[0].data;
var jsonString = JSON.stringify(evt.rows[0].data);

var value = Object["FIRSTNAME"];

domAttr.set("txtfirstName", "value", Object["FIRSTNAME"]);
domAttr.set("txtlastName", "value", Object["LASTNAME"]);
domAttr.set("txtaddress", "value", Object["ADDRESS"]);
domAttr.set("email", "value", Object["EMAIL"]);
domAttr.set("homephone", "value", Object["HOME_PH"]);
domAttr.set("mobilphone", "value", Object["MOBILE_PH"]);
domAttr.set("costtrack", "value", Object["COST_TRACK"]);

});

My question is, How to update the FeatureTable if  I update the infomation on the form?

Can I do this with a FeatureTable or I need a dgrid ?

thanks, 

0 Kudos