我正在使用 jqgrid 并且我的工具栏搜索在我使用滚动分页之前工作但现在它在滚动分页后不起作用。我使用参数 loadonce:true; 经过大量谷歌搜索但总记录未加载。我的代码如下
$(document).ready(function(){
var ageCheckbox = document.getElementById('sent_all_message');
ageCheckbox.onchange = function() {
var grid = $("#grid");
if(this.checked){
grid.jqGrid('resetSelection');
var ids = grid.getDataIDs();
for (var i=0, il=ids.length; i < il; i++) {
grid.jqGrid('setSelection',ids[i], true);
}
$('.cbox').attr('disabled', true);
$('#gview_grid #cb_grid').attr('checked',true).attr('disabled',true);
}else{
grid.jqGrid('resetSelection');
$('#gview_grid #cb_grid').attr('checked',false).attr('disabled',false);
$('.cbox').attr('disabled', false);
}
};
$.extend(jQuery.jgrid.defaults, {
prmNames: {
id: "rowid", page: "page", rows: "rows",
oper: "oper", sort: "sidx", order: "sord",
search : "search"
}
});
jQuery("#grid").jqGrid({ //set your grid id
// data: mydata, //insert data from the data object we created above
url:'adminCreateMessageGrid',
datatype: "json",
colNames:['Id','First name','Last Name','Specialty','Username','Email'], //define column names
colModel:[
{name:'id',index:'id',hidden:true,width:50,align:"center"},
{name:'first_name', index:'first_name',sortable:true, width:100,align:"center"},
{name:'last_name', index:'last_name',sortable:true, width:100,align:"center"},
{name:'description', index:'description',sortable:true, width:100,align:"center",stype:"select",
searchoptions: {
sopt:['eq'],
value: ":All;1:Family Practice;2:Obstetrics",
// defaultValue: "1"
}},
{name:'user_name', index:'user_name',sortable:true,width:100,align:"center"},
{name:'email', index:'email',sortable:true,width:170,align:"center"}
], //define column models
pager: '#pager', //set your pager div id
rowNum: 50,
sortname: 'first_name', //the column according to which data is to be sorted; optional
scroll:1,
multiSort:true,
sortable:true,
// loadonce : true,
ignoreCase: true,
scrollOffset: 1,
gridview: true,
height: 450,
width: 875,
sortorder: 'asc',
viewrecords: true, //if true, displays the total number of records, etc. as: "View X to Y out of Z” optional
multiselect: true,
shrinkToFit:true,
onSelectRow: function (id) {
var arrID = new Array();
$('.cbox').each(function(){
if($(this).attr('checked') == 'checked'){
var name = $(this).attr('id');
var id = $('#'+name).closest('tr.jqgrow').attr('id');
arrID.push(id);
}
});
$('#selectedUser').val(arrID);
// console.log(arrID.toSource());
},
caption:"Select Users", //title of grid
loadComplete: function () {
var objRows = $("#list_accounts tr");
var objHeader = $("#list_accounts .jqgfirstrow td");
if (objRows.length > 1) {
var objFirstRowColumns = $(objRows[1]).children("td");
for (i = 0; i < objFirstRowColumns.length; i++) {
$(objFirstRowColumns[i]).css("width", $(objHeader[i]).css("width"));
}
}
$('#lui_grid').remove();
}
});
//jQuery("#grid").setGridParam({rowNum:50}).trigger("reloadGrid"); jQuery("#grid").jqGrid("filterToolbar", { multipleSearch:true, recreateFilter:true, searchOperators: true,
stringResult: true, overlay:false, searchOnEnter: false, defaultSearch: "bw",
});
});
我的分页代码如下
$Page = $_GET['page'];
$OrderByOption = $_GET['sidx'];
$OrderByOptionSort = $_GET['sord'];
if (isset($OrderByOption) && $OrderByOption != '') {
if (isset($OrderByOptionSort) && $OrderByOptionSort != '') {
$OrderBy = 'ORDER BY users.first_name' . $OrderByOption . ' ' . $OrderByOptionSort;
}
}
$Limit = 50;
$arrAllUserData = $this->User_model->messagegrcountid();
$PageCount = 0;
if (count($arrAllUserData) > 0) {
if ($Limit != 0) {
$PageCount = ceil(count($arrAllUserData) / $Limit);
} else {
$PageCount = count($arrAllUserData);
}
}
if ($Page > $PageCount)
$Page = $PageCount;
if ($Page < 1)
$Page = 1;
$Start = ($Limit * $Page) - $Limit;
$arrUserData = $this->User_model->messagegrid($Start,$Limit,$OrderBy);
$ResponceData = new stdClass();
$ResponceData->total = $PageCount;
$ResponceData->page = $Page;
$ResponceData->records = count($arrAllUserData);
for ($Index = 0; $Index < count($arrUserData); $Index++) {
$ResponceData->rows[$Index]['cell'] = array($arrUserData[$Index]['id'],$arrUserData[$Index]['first_name'],$arrUserData[$Index]['last_name'],$arrUserData[$Index]['description'],$arrUserData[$Index]['user_name'],$arrUserData[$Index]['email']);
}
echo json_encode($ResponceData);
请告诉我答案