Skip to content

Instantly share code, notes, and snippets.

@danmaps
Last active April 4, 2016 14:47
Show Gist options
  • Save danmaps/5969101d38d0eef03f1d to your computer and use it in GitHub Desktop.
Save danmaps/5969101d38d0eef03f1d to your computer and use it in GitHub Desktop.
Feature Table with hyperlinks
license: gpl-3.0
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Using FeatureTable</title>
<link rel="stylesheet" href="//js.arcgis.com/3.16/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="//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>
var map;
require([
"esri/layers/FeatureLayer",
"esri/dijit/FeatureTable",
"esri/geometry/webMercatorUtils",
"esri/map",
"dojo/dom-construct",
"dojo/dom",
"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, webMercatorUtils, Map,
domConstruct, dom, parser, ready, on,lang,
registry, Button, ContentPane, BorderContainer, TextBox
) {
parser.parse();
ready(function(){
var myFeatureLayer;
var map = new Map("map",{
basemap: "dark-gray"
});
map.on("load", loadTable);
function loadTable(){
// Create the feature layer
myFeatureLayer = new FeatureLayer("http://services.arcgis.com/Wl7Y1m92PbjtJs5n/arcgis/rest/services/hyperlynk/FeatureServer/0", {
mode: FeatureLayer.MODE_ONDEMAND,
visible: true,
outFields: ["*"],
id: "fLayer"
});
//set map extent
on(myFeatureLayer, "load", function(evt){
var extent = myFeatureLayer.fullExtent;
if (webMercatorUtils.canProject(extent, map)) {
map.setExtent( webMercatorUtils.project(extent, map) );
}
});
map.addLayer(myFeatureLayer);
myFeatureTable = new FeatureTable({
"featureLayer" : myFeatureLayer,
"outFields": ["hlink","hlink2"],
"map" : map
}, 'myTableNode');
myFeatureTable.startup();
on(myFeatureTable, "load", function(evt){
console.log("The load event - ", evt);
});
myFeatureTable.on("show-statistics", function(evt){
console.log("show-statistics avgfield - ", evt.statistics.avgField);
console.log("show-statistics countfield - ", evt.statistics.countField);
console.log("show-statistics maxfield - ", evt.statistics.maxField);
console.log("show-statistics minfield - ", evt.statistics.minField);
console.log("show-statistics stddevfield - ", evt.statistics.stddevField);
console.log("show-statistics sumfield - ", evt.statistics.sumField)
});
myFeatureTable.on("row-select", function(evt){
console.log("select event - ", evt[0].data);
});
myFeatureTable.on("row-deselect", function(evt){
console.log("deselect event - ", evt[0].data);
});
myFeatureTable.on("refresh", function(evt){
console.log("refresh event - ", evt);
});
myFeatureTable.on("column-resize", function(evt){
//triggered by ColumnResizer extension
console.log("column-resize event- ", evt);
});
myFeatureTable.on("column-state-change", function(evt){
// triggered by ColumnHider extension
console.log("column-state-change event - ", evt);
});
myFeatureTable.on("sort", function(evt){
console.log("sort event - ", evt);
});
myFeatureTable.on("filter", function(evt){
console.log("filter event - ", evt);
});
}
});
});
</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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment