here is the sample code. I am expecting it to work a bit more like the FeatureTable from ArcGIS Online:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
<title>FeatureTable Formatting</title>
<link rel="stylesheet" href="https://community.esri.com//js.arcgis.com/3.16/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="https://community.esri.com//js.arcgis.com/3.16/esri/css/esri.css">
<script src="//js.arcgis.com/3.16/"></script>
<style>
html, body, #map {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
</style>
<script>
// Sample from http://developers.arcgis.com/javascript/sandbox/sandbox.html?sample=featuretable_formatting
// Globals
var map, myFeatureLayer, myFeatureTable;
require([
"esri/layers/FeatureLayer",
"esri/dijit/FeatureTable",
"esri/tasks/query",
"esri/tasks/QueryTask",
"esri/geometry/Extent",
"esri/symbols/SimpleMarkerSymbol",
"esri/symbols/SimpleLineSymbol",
"esri/Color",
"esri/map",
"dojo/dom-construct",
"dojo/dom",
"dojo/number",
"dojo/parser",
"dojo/ready",
"dojo/on",
"dojo/_base/lang",
"dijit/registry",
"dijit/form/Button",
"dijit/layout/ContentPane",
"dijit/layout/BorderContainer",
"dijit/form/TextBox"
], function (
FeatureLayer, FeatureTable,Query, QueryTask, Extent, SimpleMarkerSymbol, SimpleLineSymbol, Color, Map,
domConstruct, dom, dojoNum, parser, ready, on,lang,
registry, Button, ContentPane, BorderContainer, TextBox
) {
parser.parse();
ready(function(){
map = new Map("map",{
basemap: "dark-gray",
extent: new Extent({xmax: -13035353.854156237, xmin: -13053431.211345658,
ymax: 4038351.1313028745, ymin: 4034089.766975982,
"spatialReference":{"wkid":102100,"latestWkid":3857}
})
});
var myFeatureLayer = new FeatureLayer("http://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Redlands_Emergency_Facilities/Featu...",{
mode: FeatureLayer.MODE_ONDEMAND,
outFields: ["*"],
visible: true,
id: "fLayer"
});
//set a selection symbol for the featurelayer.
var selectionSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_SQUARE, 12,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([0, 255, 197, 1])));
myFeatureLayer.setSelectionSymbol(selectionSymbol);
map.addLayer(myFeatureLayer);
map.on("load", loadTable);
map.on("extent-change", updateTableByExtent);
function updateTableByExtent(ext){
console.log("Map Extent: ", ext.extent);
var qTask = new QueryTask(myFeatureLayer);
var q= new Query();
q.where = "1=1";
q.returnGeometry = true;
q.outFields=["*"];
q.geometry = ext.extent;
q.spatialRelationship = Query.SPATIAL_REL_CONTAINS;
qTask.execute(q, successCallBack, errorCallBack);
function successCallBack(result){
// Update the featureTable here ====> this should work more like the featureTable widget on ArcGIS Online
console.log(result);
}
function errorCallBack(err){
console.log("Ooops Error: ", err);
}
}
function loadTable(){
//create new FeatureTable and set its properties
myFeatureTable = new FeatureTable({
featureLayer : myFeatureLayer,
map : map,
gridOptions: {
allowSelectAll: true,
allowTextSelection: true,
},
editable: true,
//zoomToSelection: false, //disable pan/zoom action on the map for selected features
// showGridHeader: false,
// showGridMenu: false,
dateOptions: {
//set date options at the feature table level
//all date fields will adhere this
datePattern: "EEEE, MMMM d, y"
},
//define order and visibility of fields. If the fields are not listed in 'outFIelds'
// then they will be hidden when the table starts.
outFields: ["factype", "facname", "organiz", "capacity", "curcapacity", "hoursoper",
"daysoper", "opsstatus", "opendate", "imageurl", "pocname", "pocphone"
],
fieldInfos: [
{
name: 'factype',
alias: 'Facility Type',
},
{
name: 'hoursoper',
alias: 'Open Hours',
},
{
name: 'curcapacity',
format: {
template: "${value} people"
}
},
{
name: 'daysoper',
alias: 'Open Days',
},
{
name: 'opsstatus',
alias: 'Status',
},
{
name: 'lastupdate',
alias: 'Last Update',
//this will override FeatureTable.dateOptions
//settings
dateOptions: {
datePattern: 'M/d/y',
}
},
{
name: 'imageurl',
alias: 'More Info',
editable: false
},
{
name: 'pocphone',
alias: 'Phone #',
format: {
template: "tel: ${value}"
}
}
],
}, 'myTableNode');
myFeatureTable.startup();
}
});
});
</script>
</head>
<body class="claro esri">
<div data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'headline'" style="width:100%; height:100%;">
<div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center', splitter:true" style="height:50%">
<div id="map"></div>
</div>
<div id="bot" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'bottom', splitter:true" style="height:50%">
<div id="myTableNode"></div>
</div>
</div>
</body>
</html>