Iam using JqGrid to for data entry.
Iam showing an empty jqgrid at page load and on click of a button, add an empty row from client-side only.
On click of the empty row, it becomes editable and the new values can be added.
Any number of rows can be added and edited and all rows are in edit mode.
Now I need to get all this data and send it at once to the action in my controller.
JqGrid provides methods to retrieve row or cell data when not in edit mode.
But while in edit mode, there's no way given.
I have done the following which works for me but am not sure as to if this is the right way to do it.
$("#btnSave").click(function () {
var rows = new Array();
//rows[0] = new Array();
//Gets total count of records shown currently
var totalrec = jQuery("#rowed2").jqGrid('getGridParam', 'reccount');
//total number of columns,
//can also use"jQuery("#rowed2").jqGrid('getGridParam', 'colModel').length"
var totalCol = 4;
var totalCells = 0;
for (var i = 0; i < totalrec; i++) {
rows[i] = new Array();
for (var j = 0; j < 4; j++) {
rows[i][j] = jQuery('#rowed2').contents().children().children().children()[totalCells].value;
totalCells++;
}
}
});
I know the above code seems shabby, dirty, unprofessional, whatever you wanna call it. But works exactly how i want.
But if any of you guys have a better idea please let me know