function queryGeometryResultsHandler_toGrid(results, idx) { var myDiv = dojo.byId("attributeDiv"); var currentLayerId = qTaskNameList[idx]; var paneTitle = (currentLayerId.split('_').join(' '));//earlier all spaces were replaced _, now I need spaces for the title var tp = new dijit.TitlePane({ id: 'gridPane_'+currentLayerId, title: paneTitle}); myDiv.appendChild(tp.domNode); var itemNames = []; var featureAttributes = dojo.map(results.features, function(feature){ return feature.attributes; }); var firstFeature = featureAttributes[0]; for(var fieldName in firstFeature) { itemNames.push(fieldName); } console.log(itemNames); //gets the field names from the first feature for the grid // for (fieldName in itemNames[0]) { var currentLayout = []; var addField; dojo.forEach(itemNames, function (fieldName) { /* if (fieldName == "FID" || fieldName == "OBJECTID" ) { addField = { field: fieldName, formatter: makeZoomButton }; currentLayout.push(addField); }*/ if (fieldName == "Shape" || fieldName == "FID" || fieldName == "OBJECTID") { addField = { field: fieldName, hidden: true }; currentLayout.push(addField); } else { //console.log("field Name is " + fieldName); addField = { field: fieldName, width: "120px" }; currentLayout.push(addField); } }); console.log(currentLayout); var data = { identifer: "OBJECTID", items: featureAttributes }; var currentStore = new dojo.data.ItemFileReadStore({ data: data }); // Create Grid var grid = new dojox.grid.DataGrid({ id: currentLayerId+"_grid", store: currentStore }, document.createElement('div')); grid.startup(); var currentPane = dojo.byId('gridPane_'+currentLayerId); currentPane.appendChild(grid.domNode); // tp.appendChild(grid.domName); // tp.set("content",grid); // } }
Solved! Go to Solution.
Here's another spin on it. Apparently there is data in my datagrid, but I don't see it until I click on a column heading to sort. Then it appears. Maybe this is a style problem. Or maybe the store isn't getting read/loaded until I'm clicking a column because I have something out of sequence?
var currentPane = dojo.byId('gridPane_'+currentLayerId); currentPane.appendChild(grid.domNode); grid.startup();
var grid = new dojox.grid.DataGrid(); grid.setStructure(currentLayout); //this gives me the headers I expect on my grid grid.setStore(currentStore); //currentstore doesn't look right, I think it's empty
Here's another spin on it. Apparently there is data in my datagrid, but I don't see it until I click on a column heading to sort. Then it appears. Maybe this is a style problem. Or maybe the store isn't getting read/loaded until I'm clicking a column because I have something out of sequence?
var currentPane = dojo.byId('gridPane_'+currentLayerId); currentPane.appendChild(grid.domNode); grid.startup();
hi Tray
will you able to post your code to jsfiddle, please. I am seeking the same solution.
Thanks alot
Since you're replying to a 2 year old thread, a lot has changed since then, including updating to dGrid and AMD. Here's a sample of how I'm handling it now.