Reputation: 15031
I am facing an issue when using jqGrids.
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,
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?
Upvotes: 3
Views: 24821
Reputation: 900
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});
}
Upvotes: 13