I am working with a dojo grid and I am wondering if there is a way to format or decode the values in 2 of the columns. Right now it is just displaying a 0, 1, 2, 3, 4 or 5 and I would like to be able to see the text associated with each number in the data grid because a number is really of no use to the user. Below is my code for populating the grid. OB_AREA and OB_DENSITY are the columns/fields in question.
/* Dojo dgrid */
var resultsGrid = declare([Grid, Selection, ColumnResizer]);
var columns = [{
// label: "Object ID", //wasn't able to inject an HTML <div> with image here
// field: "OBJECTID",
// }, {
label: "Observer Name",
field: "OBSERVER"
}, {
label: "Observation Date",
field: "DAY",
formatter: formatTimestamp
}, {
label: "Latitude",
field: "LATITUDE"
}, {
label: "Longitude",
field: "LONGITUDE"
}, {
label: "Common Name",
field: "Q_NAME"
}, {
label: "Genus",
field: "GENUS"
}, {
label: "Species",
field: "SPECIES"
}, {
label: "Area",
field: "OB_AREA"
}, {
label: "Density",
field: "OB_DENSITY"
}, {
label: "County",
field: "COUNTY"
}, {
label: "State",
field: "STATE"
}, {
label: "Country",
field: "COUNTRY"
}, {
label: "Date Added",
field: "ADD_DATE",
formatter: formatTimestamp
}];
grid = new resultsGrid({
bufferRows: Infinity,
columns: columns,
selectionMode: 'single'
}, "grid");
function formatTimestamp(value) {
var inputDate = new Date(value);
return dojo.date.locale.format(inputDate, {
selector: 'date',
datePattern: 'MM/dd/yyyy'
});
}
grid.on('dgrid-select', function (event) {
var lat = event.rows[0].data.LATITUDE;
var long = event.rows[0].data.LONGITUDE;
var pt = new Point(long,lat);
view.goTo({
target: pt,
zoom: 17
});
});/* Populate DGrid Table at bottom of page with query results*/
var items = prjResults
var TableFeatures = []
array.forEach(items, function (feature) {
var TableAttributes = {}
var TableFields = Object.keys(feature.attributes)
console.log(feature.attributes.OB_AREA);
for (var i = 0; i < TableFields.length; i++) {
TableAttributes[TableFields[i]] = feature.attributes[TableFields[i]]
}
TableFeatures.push(TableAttributes)
})
var memStore = new Memory({
data: TableFeatures,
idProperty: "OBJECTID"
});
grid.set("collection", memStore);