Hi Friends,
In my MVC application i am using JQgrid .For each record selection we using Check box in this grid.
In that JQgrid we need to select one or more than one records across all pages.While going to next paging in grid the existing page selected checkbox get refreshed so i am not able to select multiple records from across all pages.
Here is my JQgrid code
function LoadForSearchGridPartial() {
var grid = $('#dgGridSearchListPartail');
grid.jqGrid({
//url: 'SearchResultJson',
datatype: function (pdata) {
getSearchGridData(1);
},
colNames: ['Select', 'ID', 'Name', 'City'],
colModel: [
{
name: 'Select',
index: 'Select',
width: 20,
formatter: "checkbox",
formatoptions: { disabled: false },
// multiselect: true,
checked: "unchecked",
editoptions: { value: 'TruFalse', defaultValue: 'false' },
search: false,
align: "center",
},
{
name: 'CompanyId',
index: 'CompanyId',
width: 55,
search: true,
hidden: true
}, {
name: 'CompanyName',
index: 'CompanyName',
width: 100,
search: true
}, {
name: 'CityName',
index: 'CityName',
width: 100,
search: true
}
],
rowNum: 10,
rowList: [10, 20, 30],
pager: '#pagerGridSearchListPartail',
sortname: 'CompanyName',
viewrecords: true,
sortorder: "asc",
caption: $("#spanTitle").text(),
width: 700,
height: 200,
rownumbers: true,
loadonce: true,
gridComplete: function () {
grid.setGridParam({ datatype: 'local' });
},
onSelectRow: function (MSG_TXT) {
var CompanyId = grid.jqGrid('getCell', CompanyId, 'CompanyId');
var CompanyName = grid.jqGrid('getCell', CompanyName, 'CompanyName');
var CityName = grid.jqGrid('getCell', CityName, 'CityName');
}
});
jQuery("#dgGridSearchListPartail").jqGrid('filterToolbar', { stringResult: true, searchOnEnter: false, defaultSearch: "cn" });
$("#dgGridSearchListPartail").jqGrid('resetSelection');
grid.jqGrid('navButtonAdd', '#pagerGridSearchListPartail',
{
caption: "Select", onClickButton: function () {
var id = grid.jqGrid('getGridParam', 'selrow');
var CompanyId = grid.jqGrid('getCell', id, 'CompanyId');
var CompanyName = grid.jqGrid('getCell', id, 'CompanyName');
var CityName = grid.jqGrid('getCell', id, 'CityName');
// alert(CFAId);
if (CompanyName) {
} else { alert("Please select Row") }
}
});
}
Can anyone please guide for this
Thanks
Loading
Ramesh MaruthiPosted Apr 22, 2015, 11:52 AM
Declare a global array and when you check the checkbox write a function and store the values in that array and, when you go to next page check for that particular array whether , its has any values or not. this solves your problem
Note :
when you uncheck the check box, write an other function to pop that selected row from the global array