Display attribute table with JavaScript API ver 4.9?

6176
10
Jump to solution
10-21-2018 11:55 PM
lxd
by
New Contributor III

How to display feature layer's attribute table with JavaScript API ver 4.9? 

I am working with ArcGIS API for Javascript 4.9. I want to create a simple map view and display a table under it. I am stuck trying to work out how to display a table displaying data from a feature layer published on ArcGIS  with this version of API. I removed all code related to the map to make it simpler till I work out this table.

Here is my code:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Tutorial: Grids and Stores</title>

<link rel="stylesheet" href="https://js.arcgis.com/4.9/esri/css/main.css">
</head>
<body class="claro">
<h1>Display table with feature layer and dgrid </h1>
<div id="grid"></div>


<script src="https://js.arcgis.com/4.9/"></script>
<script>
require([

"dojo/_base/declare",
"dstore/RequestMemory",
"dgrid/Grid",
"dgrid/extensions/Pagination"
], function (declare, RequestMemory, Grid, Pagination) {
// Create a Grid instance using Pagination, referencing the store

var gridFields = ["__OBJECTID", "WAL_NAME", "REGION", "WAL_ZONE", "REGION_WAL", // __OBJECTID
"WAL_Value", "SWAL_Value"
];


var grid = new (declare([ Grid, Pagination ]))({
collection: new RequestMemory({ target: "https://xxxxxxxxx/arcgis/rest/services/GCX/QFESAlertLevels_GCX/FeatureServer/1?f=pjson" }),
className: 'dgrid-autoheight',
columns: gridFields,

}, 'grid');

grid.startup();
});
</script>
</body>
</html>

The error that I get is:

Any ideas? Did anyone get it to work?

Thanks!

0 Kudos
10 Replies
KarstenRank
Occasional Contributor III

Thank you Robert! Now it works!

0 Kudos