它有点奇怪,但无论我做什么,寻呼机中的页码字段都没有更新。我可以输入页码,它将返回正确的记录,它会在调用时返回正确的页码信息
$('#jqGrid01').getGridParam('page')
如果我使用寻呼机按钮,它会正确刷新网格但不更新文本字段中的页码!
这是网格代码..
jQuery("#jqGrid01").jqGrid({
// data: mydata, datatype: "local",
url:'localhost/gridx/dashb_grid', mtype : "get", datatype: "json",
jsonReader: { root: "rows", page: "page", total: "total", records: "records", repeatitems: true, cell: 'cell', id: 'stock1', userdata: 'userdata'},
height: $gridh, rowNum: 100, rowList: [100,200,300,500,1000,2000,3000],
colNames:['Stock 1','Stock 2', 'Price 1', 'Price 2','Ratio','Correlation','ST % Mean', 'ST Drift', 'LT % Mean', 'LT Drift', 'RSI', 'RSI Drift', 'Beta 1', 'Beta 2', 'Industry 1', 'Industry 2', 'Earnings 1', 'Earnings 2'],
colModel:[
{name:'stock1',index:'stock1', width:30, searchoptions:{sopt:['eq','ne','cn','bw','ew','lt','gt']}},
{name:'stock2',index:'stock2', width:30, searchoptions:{sopt:['eq','ne','cn','bw','ew','lt','gt']}},
{name:'price1',index:'price1', width:30, sorttype:"float", align:"right", searchoptions:{sopt:['eq','ne','lt','gt']}},
{name:'price2',index:'price2', width:30, sorttype:"float", align:"right", searchoptions:{sopt:['eq','ne','lt','gt']}},
{name:'ratio',index:'ratio', width:30, sorttype:"float", align:"right", searchoptions:{sopt:['eq','ne','lt','gt']}},
{name:'correlation',index:'correlation', width:42, sorttype:"float", align:"right", searchoptions:{sopt:['eq','ne','lt','gt']}},
{name:'st_mean',index:'st_mean', width:38, sorttype:"float", align:"right", searchoptions:{sopt:['eq','ne','lt','gt']}},
{name:'st_drift',index:'st_drift', width:35, sorttype:"float", align:"right", searchoptions:{sopt:['eq','ne','lt','gt']}},
{name:'lt_mean',index:'lt_mean', width:39, sorttype:"float", align:"right", searchoptions:{sopt:['eq','ne','lt','gt']}},
{name:'lt_drift',index:'lt_drift', width:35, sorttype:"float", align:"right", searchoptions:{sopt:['eq','ne','lt','gt']}},
{name:'rsi',index:'rsi', width:30, sorttype:"int", align:"right", searchoptions:{sopt:['eq','ne','lt','gt']}},
{name:'rsi_drift',index:'rsi_drift', width:35, sorttype:"float", align:"right", searchoptions:{sopt:['eq','ne','lt','gt']}},
{name:'beta1',index:'beta1', width:30, sorttype:"float", align:"right", searchoptions:{sopt:['eq','ne','lt','gt']}},
{name:'beta2',index:'beta2', width:30, sorttype:"float", align:"right", searchoptions:{sopt:['eq','ne','lt','gt']}},
{name:'industry1',index:'industry1', width:102, search:false},
{name:'industry2',index:'industry2', width:102, search:false},
{name:'earnings1',index:'earnings1', width:45, sorttype:"float", align:"right", searchoptions:{sopt:['eq','ne','lt','gt']}},
{name:'earnings2',index:'earnings2', width:45, sorttype:"float", align:"right", searchoptions:{sopt:['eq','ne','lt','gt']}}
],
pager: "#jqGridPager01",
viewrecords: true, hidegrid:false,
sortname: 'stock1', sortorder: 'asc',
loadComplete: function() {
// test
}
});
还尝试检查文本框元素,但它没有ID,所以我无法手动设置它,我无法在jqGrid文档中找到任何内容或google来设置它!
知道我做错了什么,如何解决它!
由于
答案 0 :(得分:2)
您必须为您的分页添加loadonce:true
才能正常工作。
表示执行客户端分页而不是服务器端分页
此外,它表示您是loading all the records at the same time
如果您一次不想加载所有记录,那么您需要在网址中处理分页参数的情况完全不同在服务器端获取数据。
当您使用服务器端分页时,jqgrid会自动发布名为page
和rows
的参数。
此处,Page表示您所在的当前页面,行表示每页的记录数。
因此,您需要将这些参数发送到数据库并相应地获取以获取数据页面。
因为,您提到数据类型为JSon ,表示服务器端处理。你对assumes
感兴趣的Server side paging
。
它希望您在JSOn响应中返回页面和行。由于您的json不包含任何这些,因此默认显示为零。
所以,pagination obviuosly will not work
。
如果您在服务器端使用dotnet:这是一个小例子:
[HttpPost]
public JsonResult LoadPackages(int page, int rows, string sord, string sidx, string PackageNumber)
{
liPackages = new List<PackageModel>();
if (PackageNumber == "")
{
liPackages = _packageRepository.LoadPackages((page - 1) * rows, rows, sord, sidx, out strTotalRecords);
long lCount = Convert.ToInt64(strTotalRecords);
return Json(new
{
total = Math.Ceiling((Decimal)lCount / (Decimal)rows),
page = page,
records = lCount,
rows = liPackages
},
JsonRequestBehavior.AllowGet);
}
}
<强> Updated2:强>
您可以尝试加入gridview:true
<强> Updated3 强>
将方法类型从GET更改为POST,如下所示:mType:POST