AnsweredAssumed Answered

Add Attachments to OnDemandGrid

Question asked by jfaron44 on Feb 19, 2020
Latest reply on Feb 20, 2020 by jfaron44

I'm working with api 3.31. I have an app that loads an onDemandGrid via a datastore that is loaded by a querytask. It works fine, except that I need to get attachments that exist in the source data, and put the attachment into a column that is added in the createGrid function: queryAttachmentsInfo does not seem to be available via the QueryTask. So I wonder if anyone has dealt with this problem of getting attachments into a datagrid, and perhaps any suggestions as to how I could populate the attachments column in this application's grid.


Here is the code that creates the grid:

function createGrid() {
var egrid = declare([ Grid, Keyboard, Selection]);
this.gridlist = new egrid({
selectionMode: 'single',
columns: {
NAME: "Name",
HIGH_SIDE_VOLTAGE: "High Side Voltage",
OWNERSHIP_CODE: "Ownership",
ADDRESS: "Address",
CITY: "City",
COUNTY: "County",
STATE: "State",
Attachments: { label: "Attachments", formatter: makeLink}
showHeader: true,
minRowsPerPage: 200,
queryOptions: {
sort: [{ attribute: "NAME" }]
store: new Memory({data: [], idProperty: "id"})
}, "grid");

And this is where I create the store:

function loadSubstations () {
var queryTaskSubstations = new QueryTask(facilityLayer.url);
var query = new Query();
query.returnGeometry = true;
query.where = "1=1";
queryTaskSubstations.execute(query, lang.hitch(this, showResults));
function showResults (results) {
var resultFeatures = results.features;
var featureCount = results.features.length;
for (var i = 0; i < featureCount; i++){
var features = results.features[i];
var subs =, function (feature) {
return {
"id": feature.attributes["OBJECTID"],
"NAME": feature.attributes["NAME"],
"LIFE_CYCLE_STATUS": feature.attributes["LIFE_CYCLE_STATUS"],
"HIGH_SIDE_VOLTAGE": feature.attributes["HIGH_SIDE_VOLTAGE"],
"OWNERSHIP_CODE": feature.attributes["OWNERSHIP_CODE"],
"ADDRESS": feature.attributes["ADDRESS"],
"CITY": feature.attributes["CITY"],
"COUNTY": feature.attributes["COUNTY"],
"STATE": feature.attributes["STATE"],
"shape": feature.geometry

subdataStore = new Memory({data:subs, idProperty:"id"});
this.gridlist.set("store", subdataStore);
this.gridlist.set("collection", subdataStore);


 Jim Faron