Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion js/DataGridRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,41 @@ var DataGridRenderer = {
return outputText;
},

//---------------------------------------
// Javascript Object
//---------------------------------------

javascript: function (dataGrid, headerNames, headerTypes, indent, newLine) {
//inits...
var commentLine = "//";
var commentLineEnd = "";
var outputText = "var mrDataConverterObj = JSON.parse('[";
var numRows = dataGrid.length;
var numColumns = headerNames.length;

//begin render loop
for (var i=0; i < numRows; i++) {
var row = dataGrid[i];
outputText += "{";
for (var j=0; j < numColumns; j++) {
if ((headerTypes[j] == "int")||(headerTypes[j] == "float")) {
var rowOutput = row[j] || "null";
} else {
var rowOutput = '"' + ( row[j] || "" ) + '"';
};

outputText += ('"'+headerNames[j] +'"' + ":" + rowOutput );

if (j < (numColumns-1)) {outputText+=","};
};
outputText += "}";
if (i < (numRows-1)) {outputText += ","};
};
outputText += "]');";

return outputText;
},


//---------------------------------------
// JSON properties
Expand Down Expand Up @@ -535,4 +570,4 @@ var DataGridRenderer = {

},

}
}