FeatureTable formatter frustrations

3422
7
12-09-2015 11:17 AM
SteveCole
Frequent Contributor

[say that three times fast]

So I'm getting frustrated with the FeatureTable dijit since it seems like a half done widget. The layer I am displaying with the featureTable has a date field along with several double fields that represent currency. In Arcmap, I tried set the aliases for all columns and tried applying a format as well. When the mXD was published as a service, the field name aliases appear but the formatting doesn't.

As I learned from another thread, ESRI has actually "turned off" the date formatter that you can specify during construction of the widget (nice of you to note this in your documentation, ESRI!) so that leaves me currently.....screwed.

What I have tried to do is create formatter functions in my app and then specify them to the appropriate dGrid columns using Set:

var dateField = myTable.colums[6];
var drCostField = myTable.columns[9];
dateField.set('formatter',formateDate);
drCostField.set('formatter',formatCurrency);   

This does....nothing. And, from what I can see, there is not refresh method on the featureTable.

Has anyone overcome this?..

Steve

0 Kudos
7 Replies
ChrisSmith7
Frequent Contributor

According to the API documentation, it doesn't say anything about it being in beta. I saw the thread you mentioned - FeatureTable dijit appears to ignore the dateOptions - Kelly Hutchins​ said the doc would be updated - that was back around API v3.12 As far as the documentation is concerned, it should work!

SteveCole
Frequent Contributor

Yeah. I bumped that thread for an update to no avail. It just feels like it's in beta with the glaring deficiencies. Since there is no refresh method, I did create a request on the ArcGIS Ideas website.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Yep, I can confirm that the dateOptions > datePattern still does not work in 3.15

0 Kudos
ChrisSmith7
Frequent Contributor

Something does appear to happen when you enable time:

<!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.15/dijit/themes/claro/claro.css">
  <link rel="stylesheet" href="https://community.esri.com//js.arcgis.com/3.15/esri/css/esri.css">
  <script src="//js.arcgis.com/3.15/"></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("https://services.arcgis.com/V6ZHFr6zdgNZuVG0/ArcGIS/rest/services/Apple_Stores/FeatureServer/0", {
          mode: FeatureLayer.MODE_ONDEMAND,
          outFields:  ["Store", "Opening_Date"],
          visible: true,
          id: "fLayer"
        });
        myTable = new FeatureTable({
          "featureLayer" : myFeatureLayer,
          "dateOptions": {"datePattern" : "yyyyMMdd", "timeEnabled" : true, "timePattern": "HH:mm:ss"}
        }, 'myTableNode');
        myTable.startup();
      });
    });
  </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>

Formatting still isn't right, though...

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Correct the timeEnabled is the only option that works.

0 Kudos
ChrisSmith7
Frequent Contributor

I did some quick debugging:

Line 299 (pretty-printed in http://js.arcgis.com/3.15/esri/dijit/FeatureTable.js😞

l ? B ? b.push(this._generateDateTimeEditorColumn(a, this._layerInfo._fieldInfo)) :

We don't seem to ever get into _generateDateTimeEditorColumn, which is the only place I found tapping into the formatter. Instead, we go into _generateDateTimeColumn, which only has a reference to timeEnabled. Seems like it's missing functionality... But, that had me wondering, the API does specifically say:

Object defining the date options specifically for formatting date and time editors.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Chris,

   Good catch I missed the "editors" part.

0 Kudos