Así se cargaría manualmente un json a una grilla de jqgrid. Espero les sirva:
SIENDO EL HTML
<table id="tableValidations"><tr><td></td></tr></table>
<div id="pagerValidations"></div>
SIENDO EL JAVACRIPT:
$("#tableValidations").jqGrid({
datatype: 'local',
colNames:['Puntuación','Campo', 'Valor', 'Valor PDF'],
colModel:[
{ name: 'FieldScore', key: true, width: 100 },
{ name: 'FieldName', width: 150 },
{ name: 'FieldValue', width: 325 },
{ name: 'FieldValueVerified', width: 325 }
],
pager: "#pagerValidations",
rowNum:10,
rowList:[3,6],
gridview: true,
width:900,
viewrecords: true,
caption: "Validaciones"
});
//resultDataValidations contiene un ARRAY DE OBJETOS
for (var i = 0; i < resultDataValidations.length; i++) {
var objectRow = {};
console.log('objeto a insertar', resultDataValidations[i]);
objectRow.FieldScore = resultDataValidations[i].FieldScore;
objectRow.FieldName = resultDataValidations[i].FieldName;
objectRow.FieldValue = resultDataValidations[i].FieldValue;
objectRow.FieldValueVerified = resultDataValidations[i].FieldValueVerified;
console.log('objeto insertado', objectRow);
jQuery("#tableValidations").jqGrid('addRowData', i + 1, objectRow);
}
Sean felices! :) Y siéntanse libres de opinar ;)
Excelente!
ResponderEliminarme salvaste el día :D
ResponderEliminar