The method getRowData
has no option to export only visible data. So if you need to have the data I can suggest you two implementation ways:
- You can get all data using
getRowData
and then remove unneeded properties from every item of resulting data. The call $('#list').jqGrid('getGridParam', 'colModel')
get you array of columns of the grid. Every item of colModel
array contain hidden
property. If the hidden
property is true
then the corresponding column is non-visible and you can delete name
property of the item from all items of array returned by getRowData
.
- You can define your own modification of
getRowData
which export only visible data. To do this you need make copy of the source code of getRowData
(see here), make modification of the line from
if ( nm !== 'cb' && nm !== 'subgrid' && nm !== 'rn') {
to
if ( nm !== 'cb' && nm !== 'subgrid' && nm !== 'rn' && !$t.p.colModel[i].hidden) {
The resulting method will do what you need.
I described in the answer how you can add new method to jqGrid. So your code can be something like
$.jgrid.extend({
getVisibleRowData: function(rowid) {
// here can be the copy of the code of getRowData
// starting with the line
// var res = {}, resall, getall=false, len, j=0;
// see https://github.com/tonytomov/jqGrid/blob/v4.5.2/js/grid.base.js#L3027-L3061
// you need just make the described above
// modification of one line of the code
}
});
You can use new method by name: $('#list').jqGrid('getVisibleRowData')
.