动态设置jqGrid RowNum [英] Setting jqGrid RowNum dynamically

查看:496
本文介绍了动态设置jqGrid RowNum的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 jqGrids 时遇到问题.

我有一个jqGrid,它的rowNum设置为10.我的JavaScript代码中有这个:

I have a jqGrid whose rowNum is set to 10. I have this in my JavaScript code:

rowNum: 10,
height: 160,
width: 742,
shrinkToFit: false,
sortname: 'CreditRequestID',
sortorder: "asc",
viewrecords: true,

现在,我的填充网格源在模型中.假设我的model.SearchResults有25条记录.因此,第一次加载此网格时,我正在填充10条记录.我还有一个..链接,当单击该链接时,应向网格中再添加10条记录,因此显示的总数为20.

Now my source for populating the grid is in the model. So say my model.SearchResults has 25 records. So the first time this grid is loaded I am populating 10 records. I have a more.. Link, which when clicked, should add 10 more records to the grid so total displayed is 20.

我的网格还将执行以下控制器代码:

My grid will also execute the following controller code:

public ActionResult RecentActivityResultsGridEventHandler(string sidx, string sord,
                                                          int page, int rows)
{
    int pageIndex = Convert.ToInt32(page) - 1;
    int pageSize = rows;
    int totalRecords = 20;
    int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);
    var JSONData = {//code to read the records from model.SearchResults 
                     //and assign column by column to grid
                   }
}

每次用户单击more..链接时,如何动态增加网格的rowNum 10?

How can increment rowNum of the grid by 10 dynamically each time when the user clicks the more.. link?

推荐答案

如果您需要做的就是增加rowNum属性,则可以使用getGridParam和setGridParam函数:

If all you need to do is increment the rowNum property, then you can use the getGridParam and setGridParam functions:

function incrementRowNum(gridName){
    var grid = $('#'+gridName);
    var currentValue = grid.getGridParam('rowNum');
    grid.setGridParam({rowNum:currentValue+10});
}

这篇关于动态设置jqGrid RowNum的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆