Skip to content

Instantly share code, notes, and snippets.

@odoe
Created September 14, 2011 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save odoe/1216974 to your computer and use it in GitHub Desktop.
Save odoe/1216974 to your computer and use it in GitHub Desktop.
JavaScript function to parse WebOrb results to a Dojo DataGrid
/******************************************
/* Response handler that can parse
/* WebOrb (webORB.js) results and load data
/* to Dojo DataGrid
*******************************************/
function handleResponse( result )
{
var count = result.getTotalRowCount();
var colNames = result.getColumnNames();
var colCount = colNames.length;
result.getRecords(1, count, new Async(function(records) {
var page = records.Page;
var d = [];
for (var i=0; i < count; i++) {
var row = {};
for (var x=0; x < colCount; x++) {
var s = "";
try {
s = page[i][x].toString();
} catch(err) {
console.log(err);
}
row[colNames[x]] = s;
}
d.push(row);
}
var dGrid = dijit.byId("grid");
var store = new dojo.data.ItemFileWriteStore({
data: {
items: d
}
});
dGrid.setStore(store);
}));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment