Created
September 14, 2011 16:06
-
-
Save odoe/1216974 to your computer and use it in GitHub Desktop.
JavaScript function to parse WebOrb results to a Dojo DataGrid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/****************************************** | |
/* 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