jqgrid filter issue
by cubicalmonkey
HTML
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/themes/base/jquery-ui.css">
<link rel="stylesheet" href="http://trirand.com/blog/jqgrid/themes/ui.jqgrid.css">
<script src="http://trirand.com/blog/jqgrid/js/i18n/grid.locale-en.js"></script>
<script src="http://trirand.com/blog/jqgrid/js/jquery.jqGrid.min.js"></script>
<table id="list"></table>
<div id="pager"></div>
<p>check in console for filtered data list</p>
<input type="button" value="show Filtered records" onclick="getRows()" />
<input type="button" value="show Filtered records1" onclick="getRows1()" />
JavaScript
var getRows = function () {
// all data coming irrect
var grid = $("#list");
// var myData = grid.jqGrid('getGridParam', 'lastSelectedData');
var filteredData = grid.jqGrid('getGridParam', 'lastSelected')
console.log("grid.jqGrid('getGridParam', 'data');");
console.log(filteredData);
//shows only first page filtered data
}
var getRows1 = function () {
//shows only first page filtered data
var grid = $("#list");
var myData = grid.jqGrid('getRowData');
console.log(" grid.jqGrid('getRowData');");
console.log(myData);
}
var oldFrom = $.jgrid.from,
lastSelected;
$.jgrid.from = function (source, initalQuery) {
var result = oldFrom.call(this, source, initalQuery),
old_select = result.select;
result.select = function (f) {
lastSelected = old_select.call(this, f);
return lastSelected;
};
return result;
};
var mydata = [{
id: "1",
invdate: "2010-05-24",
name: "test",
note: "note",
tax: "10.00",
total: "2111.00"
}, {
id: "2",
invdate: "2010-05-25",
name: "no",
note: "note2",
tax: "20.00",
total: "320.00"
}, {
id: "3",
invdate: "2007-09-01",
name: "test3",
note: "note3",
tax: "30.00",
total: "430.00"
}, {
id: "4",
invdate: "2007-10-04",
name: "test4",
note: "stuff",
tax: "10.00",
total: "210.00"
},
{
id: "5",
invdate: "2007-10-04",
name: "test5",
note: "stuff",
tax: "10.00",
total: "210.00"
}, {
id: "6",
invdate: "2007-10-04",
name: "test6",
note: "stuff",
tax: "10.00",
total: "210.00"
}, {
id: "7",
invdate: "2007-10-04",
name: "test",
note: "stuff",
tax: "10.00",
total: "210.00"
},
];
jQuery("#list").jqGrid({
data: mydata,
datatype: "local",
height: 150,
rowNum: 5,
rowList: [10, 20, 30],
colNames: ['Inv No', 'Date', 'Client', 'Amount', 'Tax', 'Total', 'Notes'],
colModel: [{
...