function CreateDynamicTable(objArray) {
//var array = JSON.parse(objArray);
//debugger;
var array = objArray;
var str = '<table class="display" cellpadding="0" cellspacing="0" border="0" id="example">';
str += '<thead><tr>';
for (var index in array[0]) {
str += '<th scope="col">' + index + '</th>';
}
str += '</tr></thead>';
str += '<tbody>';
for (var i = 0; i < array.length; i++) {
str += (i % 2 == 0) ? '<tr class="gradeA">' : '<tr class="gradeA">';
for (var index in array[i]) {
if (index == "Date") {
str += '<td>' + array[i][index] + '</td>';
}
else {
str += '<td>' + array[i][index] + '</td>';
}
}
str += '</tr>';
}
str += '</tbody>'
str += '<tfoot><tr>';
for (var index in array[0]) {
str += '<th scope="col">' + index + '</th>';
}
str += '</tr></tfoot>';
str += '</table>';
return str;
}
No comments:
Post a Comment