开发者

Setting jqGrid RowNum dynamically

开发者 https://www.devze.com 2022-12-20 01:07 出处:网络
I am facing an issue when using jqGrids. I have a jqGrid whose rowNum is set to 10. I ha开发者_开发技巧ve this in my JavaScript code:

I am facing an issue when using jqGrids.

I have a jqGrid whose rowNum is set to 10. I ha开发者_开发技巧ve this in my JavaScript code:

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

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
                   }
}

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


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});
}
0

精彩评论

暂无评论...
验证码 换一张
取 消