Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jqgrid - items per page

I can't configure items per page for jqgrid. My jqgrid is:

        jQuery('#EmployeeTable').jqGrid({
            url: '/Admin/IdeasJSON',
            datatype: 'json',
            postData: { page: page, pageIndex: pageIndex, Filter: Filter, DateStart: DateStart, DateEnd: DateEnd, TagID: TagID, StatusID: StatusID, CategoryID: CategoryID, IsDescription: IsDescription },
            loadComplete: function () { pageIndex = null },
            jsonReader: {
                page: "page",
                total: "total",
                records: "records",
                root: "rows",
                repeatitems: false,
                id: ""
            },

....

and MVC method returns:

        var result = new JsonResult()
        {
            Data = new { page = page, total = total, records = totalCount, rows = IdeaForJSONs }
        };
        result.JsonRequestBehavior = JsonRequestBehavior.AllowGet;

        return result;

where IdeaForJSONs has 50 elements. I don't know why but grid shows 20 elements. Why?

like image 708
Oleg Sh Avatar asked Jun 16 '11 19:06

Oleg Sh


People also ask

How to set pager in jqGrid?

The Navigation Bar, also known as the pager, is enabled by placing a <div> right after the <table> definition in your HTML . Note that it is a <div>, not a <table>. Then, you identify the <div> to your grid by placing the name of the div in the grid setting called “pager”.


1 Answers

Have a look at the rowNum option. From the documentation:

Sets how many records we want to view in the grid. This parameter is passed to the url for use by the server routine retrieving the data. Note that if you set this parameter to 10 (i.e. retrieve 10 records) and your server return 15 then only 10 records will be loaded.

The default value is 20, which explains why you are only seeing this many rows.

If you increase it to 50 you should see all of your data in the grid:

jQuery('#EmployeeTable').jqGrid({
        url: '/Admin/IdeasJSON',
        ...
        rowNum: 50,
like image 106
Justin Ethier Avatar answered Oct 27 '22 04:10

Justin Ethier