I'm dynamically creating a dGrid/OnDemandGrid and I'm having a hard time getting the ColumnResizer extension to work. Maybe it doesn't do what I think it's supposed to do? I was expecting it to allow me to grab the edge of the header and drag the column to a larger size. Is that not what it does? I have the appropriate require definitions at the top for
"dgrid/OnDemandGrid", "dgrid/extensions/ColumnHider","dgrid/extensions/DijitRegistry","dgrid/extensions/ColumnResizer","dgrid/Selection",
My grids are generated based on the results of multiple queryTasks, coming out of a set of functions based on promise/all. I have a separate function, buildColumns, to generate the columns using the attributes of each layer. I assume this buildColumns function is where I should tell each column that it's resizable. The grids are populated with the correct data.
function queryGeometryResultsHandler_toGrid(results, idx) { //format the data for the data grid
//gridList.length = 0;
var featureAttributes = arrayUtil.map(results.features, function(feature){
return feature.attributes;
});
var currentMemory = new Memory ({data:featureAttributes, idProperty:'OBJECTID'});
var gridcolumns = [];
if (results.features.length > 0) {
gridcolumns = buildColumns(results.features[0]);
}
//create a titlePane in the floatingPane for each visible layer
var currentLayerId = qTaskNameList[idx];//a list of layers created in query task functions, array created previously
var currentQTask = qTaskList[idx];
var paneTitle = (currentLayerId.split('_').join(' '))+" ("+results.features.length+")";//formats string to make a nice title
tp = new TitlePane({
id: 'gridPane_'+currentLayerId,
title: paneTitle,
splitter:true});
tp.set('class', 'reportTitlePane');
registry.byId("reportContainer").addChild(tp);
tp.startup();
// Create Grid using structure and data defined above
if (results.features.length > 0) {
var grid = new (declare([Grid, ColumnHider, DijitRegistry, ColumnResizer]))({
id:currentLayerId+'_grid',
columns: gridcolumns,
store: currentMemory
});
grid.startup();
tp.set("content", grid);
grid.on('.dgrid-row:click', function(event){
highlightGridSelection(event, grid, currentQTask);
});
}else {
tp.set("content", "No features found");
}
}
function buildColumns(feature) {
var attributes = feature.attributes;
var columns = [];
for (var attribute in attributes) {
if (attributes.hasOwnProperty(attribute)) {
var objects = {};
objects.label = attribute;
objects.field = attribute;
objects.id = attribute;
objects.resizable = true;//is this in the right place??
if (attribute === "Shape.len" || attribute === 'Shape.area' || attribute === 'OBJECTID') {
objects.hidden = true;
}
columns.push(objects);
}
}
return columns;
}