0
var jqDataUrl = "@Url.Action("transaction")";
$(document).ready(function () {
    $('#jqgProducts').jqGrid({
        url: jqDataUrl,
        datatype: 'json',
        mtype: 'POST',
        colNames: ['Name', 'Reson', 'Start Date', 'End Date', 'No of Days'],
        //columns model
        colModel: [
            { name: 'Name', index: 'Name', align: 'left', width:175},
            { name: 'Reson', index: 'Reson', align: 'left' , width:75},
            { name: 'Start Date', index: 'StartDate', align: 'left', width:100 },
            { name: 'End Date', index: 'EndDate', align: 'left',width:100  },
            { name: 'No Of Days', index: 'NoOfDays', align: 'left', width:75 },
        ],
        pager: $('#jpProducts'),
        rowNum: 10,
        sortname: 'StartDate',
        sortorder: 'desc',
        viewrecords: true,
        height: '100%'
    });

this is my jquery grid. Its working. But I cant go through the page of grid. It views only first page. arows of the bottom of grid not working. I cant go to the next page. Can anyone help me to fix it?

Oleg
  • 220,925
  • 34
  • 403
  • 798
user1662380
  • 87
  • 1
  • 8

2 Answers2

0

I suppose that your code in the action @Url.Action("transaction") ignore the page and rows which jqGrid sent to the server. You use datatype: 'json' without loadonce: true option. So you have to implement server side paging of data.

See for example the answer for code example which shows how to implement server side paging, sorting and searching.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
0

If you dont want to implement server side paging/sorting you can use loadonce:true option.

But if you want to implement server side sorting, firstly you method transaction should be ready to accept the following parameters

public ActionResult transaction(string page, string rows, string sidx, string sord)
{}

If you have worked with JqGrid before you will no doubt be familiar with the default parameters passed to any ajax request: “page”, “rows”, “sidx” & “sord”.

These parameters correspond to current page, records per page, sort column, and sort order respectively.

Here is an article on : How to use JqGrid with ASP.NET MVC also there is an another great article by Phil Haack on this here.

This article, will also be useful when implement server side paging and sorting for any thing.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Yasser Shaikh
  • 46,934
  • 46
  • 204
  • 281