tags:

views:

459

answers:

2

Hi, I am facing an issue when using JQGrids.

I have a JQGrid whose rowNum is set to 10. I have this code in my javascript:

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

I wanted to increment rowNum of the grid by 10 dynamically each time when the user clicks the more.. link. Any help would be appreciated.

+2  A: 

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});
}
Pete Amundson
A: 

Are you sure this works? I am trying to change the number of rows shown in the grid when the browser is resized. My JS looks something like this:

var rows = ($(window).height()/24).toFixed(0); //this gives the the correct number of rows $('#grid').setGridParam({rowNum:rows});

This is in a function that is called when the browser is resized. The number of rows does not change, however...?

Franz