I am using FeatureTable for the first time, attempting to use it instead of dGrid (just for fun, you know). My AGS server is still at 10.2.2. I'm using version 3.16 of the API.
My featureLayer is defined as:
app.pointFLayer = new FeatureLayer (pathName+"/arcgis/rest/services/DHSS/mysecure/LayerMapServer/0", { id: "resFLayer", outFields: ["*"], opacity: 0.0 });
I have a load function on this layer to generate the table:
//populate the table in the footer
app.pointFLayer.on ("load", function (fl) { myFeatureTable.initTable(); });
Here's that function:
define([ "dojo/dom", "esri/dijit/FeatureTable" ], function(dom, FeatureTable){ return { initTable: function(){ app.Table = new FeatureTable({ featureLayer: app.pointFLayer, map: app.map, dateOptions: { datePattern: 'MMMM d, y' }, // outFields: ["Kit_Serial_Number", "Address", "City", "State", "Zip", "County", "Analysis_Date", "Final_Result", "Loc_Code"], fieldInfos: [{ name: 'Kit_Serial_Number', alias: 'Kit Serial Number' }, { name: 'Address', alias: 'Address' }, { name: 'City', alias: 'City' }, { name: 'State', alias: 'State' }, { name: 'Zip', alias: 'ZIP' }, { name: 'County', alias: 'County' }, { name: 'Analysis_Date', alias: 'Analysis Date' }, { name: 'Final_Result', alias: 'Final Result' }, { name: 'Loc_Code', alias: 'Location Code' }] }, dom.byId('tableDiv')); app.Table.startup(); return app.Table; } } });
There are a lot of points in this layer, over 20K. I know this isn't great, but it's what the users asked for. I'm going to add some query capabilities that will eventually limit the results to something more reasonable. In the meantime, this processes a while and eventually gives me this error:
init.js:199 SyntaxError: Unexpected char ] in label.dgrid-hider-menu-label.hider-menu-label-0[for=[object HTMLDivElement]_grid-hider-menu-check-0](…) "SyntaxError: Unexpected char ] in label.dgrid-hider-menu-label.hider-menu-label-0[for=[object HTMLDivElement]_grid-hider-menu-check-0]
at q (https://js.arcgis.com/3.16compact/put-selector/put.js:4:496)
at r._renderHiderMenuEntry (https://js.arcgis.com/3.16compact/dgrid/extensions/ColumnHider.js:4:32)
at r._renderHiderMenuEntries (https://js.arcgis.com/3.16compact/dgrid/extensions/ColumnHider.js:3:115)
at r.renderHeader (https://js.arcgis.com/3.16compact/dgrid/extensions/ColumnHider.js:6:243)
at m (https://js.arcgis.com/3.16compact/init.js:96:92)
at A.renderHeader (https://js.arcgis.com/3.16compact/dgrid/extensions/ColumnResizer.js:6:363)
at Object.h.around.advice (https://js.arcgis.com/3.16compact/init.js:234:254)
at g.(anonymous function).h [as renderHeader] (https://js.arcgis.com/3.16compact/init.js:234:44)
at h._updateColumns (https://js.arcgis.com/3.16compact/dgrid/Grid.js:13:215)
at h._setColumns (https://js.arcgis.com/3.16compact/dgrid/Grid.js:12:340)
----------------------------------------
rejected at a (https://js.arcgis.com/3.16compact/init.js:190:337)
at k (https://js.arcgis.com/3.16compact/init.js:190:89)
at q (https://js.arcgis.com/3.16compact/init.js:189:357)
at resolve (https://js.arcgis.com/3.16compact/init.js:191:441)
at https://js.arcgis.com/3.16compact/esri/dijit/FeatureTable.js:22:50
at r._resolve (https://js.arcgis.com/3.16compact/esri/layers/FeatureLayer.js:159:236)
at https://js.arcgis.com/3.16compact/esri/layers/FeatureLayer.js:162:498
at c (https://js.arcgis.com/3.16compact/init.js:66:221)
at d (https://js.arcgis.com/3.16compact/init.js:66:10)
at resolve.callback (https://js.arcgis.com/3.16compact/init.js:67:350)
----------------------------------------
Error
at then.b.then (https://js.arcgis.com/3.16compact/init.js:192:253)
at D._queryFeatureLayerSetup (https://js.arcgis.com/3.16compact/esri/dijit/FeatureTable.js:22:231)
at https://js.arcgis.com/3.16compact/init.js:167:296
at c (https://js.arcgis.com/3.16compact/init.js:66:221)
at d (https://js.arcgis.com/3.16compact/init.js:66:10)
at resolve.callback (https://js.arcgis.com/3.16compact/init.js:67:350)
at c (https://js.arcgis.com/3.16compact/init.js:66:436)
at d (https://js.arcgis.com/3.16compact/init.js:66:10)
at resolve.callback (https://js.arcgis.com/3.16compact/init.js:67:350)
at Object.e._resDfd (https://js.arcgis.com/3.16compact/init.js:749:238)"
I've tried with the outFields defined and with them commented out. There aren't any characters ] in my field names. The service is secure, but see my attachment for the field names for this layer. Hopefully someone spots something I've missed.
Solved! Go to Solution.
You are still passing the id for the srcNodeRef parameter for FeatureTable. As suggested try passing the dom node instead of string.
If you pass the dom node don't work. You should pass the id.
I actually tried it that way first, and it didn't work either. So I went back to Robert's syntax that did include .id.
I can see that it is loading something, but I only seem to be getting the main grid container and some elements of the grid menu. I'm thinking it could be something as basic as an error in the field names. I keep paring those down, and maybe that's still where the problem
lies.
If you pass the dom node don't work. You should pass the id.
Besides you are using the 3.15 compact version of the api but the 3.16 version of the css. That causes troubles.
I recommend using the 3.16 version because i had problems with the feature table in 3.15.
Again, in ArcGIS API for JavaScript Sandbox if you put the css in 3.16 but the js in 3.15 it don't work. Also if you change all to 3.15 in the same example you will notice that the events don't work and you will see a warning in the console.
As I mentioned before, I've tried variations on this part of the definition, with a node or simply the id of the node and still no table, only parts of it seem to be getting created.
OK, I think I have the right combination now. Fixing the versions of css and api combined with using an existing div, as opposed to creating a new one on the fly worked for me.
app.Table = new FeatureTable({
featureLayer: app.pointFLayer,
map: app.map},
'gridDiv');
Excelent. Anyway you should be able to create a new one div on the fly and then create the table like Bill does it.