I want to get the jGrid data after it has been loaded.
Some columns have formatter but I want to get their original data before format.
The grid columns are :
<sjg:gridColumn name="accountNo" formatter="linkBulider" />
<sjg:gridColumn name="amount" />
I use below js:
var allRowsInGrid = $('#gridtable').jqGrid('getRowData');
for (i = 0; i < allRowsInGrid.length; i++) {
//For accountNo I get the formmated value
allRowsInGrid[i].accountNo;
//The amount is ok as it is unformated
allRowsInGrid[i].amount;
}
According to wiki getRowData
doesn't return the actual data from the grid.
Returns an array with data of the requested
id = rowid
. The returned array is of typename:value
, where the name is a name fromcolModel
and the value from the associated column in that row. It returns an empty array if therowid
can not be found.
- Do not use this method when you are editing the row or cell. This will return the cell content and not the actuall value of the input element.
- The performance of this method becomes an issue. Do not use this method in the body of “for” and “when”. (When calling this method, it will calculates the row datas one time.)
If the
rowid
is not set the method return all the data from the grid in array
Once you used a custom formatter
option to format a cell content, you need an option to unformat the data.
The question is: What to do if we use a custom
formatter
function and want to to have the original value back if we use editing or methodsgetRowData
andgetCell
?The answer is: You can use your own custom
unformatter
function to do that. This function can be used incolModel
.
At this point you might check if the sjg:gridColumn
could be set an attribute to define unformat
function. Unfortunately, you can't do it according to TLD.
However, you can modify the grid after it's loaded.
$(document).ready(function(){
$("#gridtable").jqGrid('setColProp', 'accountNo',{
unformat: unformatFunc
}).trigger("reloadGrid");
});