0
votes

I am working in MVC3 and using jqGrid 4.4.1, I am new to jqGrid so this is basic question.

I have successfully geting data to Grid and showing first site. But when I click next page, I don't get any response.

var myMeasurementsGrid = $("#gridMeasurementsTableView" + randomId);

myMeasurementsGrid.jqGrid({
        url: '/DataMonitor/CreateMeasurementTableView/',
        datatype: "json",
        mtype: 'POST',
        postData: { "mrpId": dataToSend.mrpId, "chartId": dataToSend.chartId, "mrpStartTime": dataToSend.mrpFilter.FilterTimeWindow.StartTimeStamp, "mrpEndTime": dataToSend.mrpFilter.FilterTimeWindow.EndTimestamp },
        jsonReader : {
            root: "data",
            page: "Page",
            total: "total",
            records: "records",  
            repeatitems: false,
            cell: "cell",
            id: "id" 
           },  
        colNames: ['Date', 'Value'],
        colModel: [
            { name: 'Timestamp', index: 'Timestamp', width: 260, 
                formatter: function (cellvalue, options, rowObject) {
                        return new Date(parseInt(cellvalue.substr(6, cellvalue.length - 8), 10));
                    }  
            },
            { name: 'Value', index: 'Value', width: 160, align: 'center' }  
        ],
        loadui: "disable",
        loadtext: "Loading",
        viewrecords: true,
        gridview: true,
        rowNum: 10,
        height: "100%",
        caption: "Measurements2",
        pager: $("#gridpager" + randomId),
        loadonce: true,
        sortname: 'Timestamp',
        sortorder: "asc",
        rowList: [10, 50, 100]
    });

Function behind is:

     [HttpPost]
        public ActionResult CreateMeasurementTableView(string sidx, string sord, int page, int rows, int mrpId, string divId, string chartId, DateTime mrpStartTime, DateTime mrpEndTime)
        {
... here is my code, for getting data

return Json(new
            {
                total = listaAvailableMeasurements.Count(),
                records = listaAvailableMeasurements.Count(),
                data = listaAvailableMeasurements,
                Page = page,
                SortColumn = sidx,
                SortOrder = sord
            });

does anyone have an idea, why is not navigation responding?

br, Jan

1

1 Answers

0
votes

Probably you returned from the server (CreateMeasurementTableView) only the first page. If you use loadonce: true you should return all data. In case of usage loadonce: true jqGrid change the datatype to "local" after the first loading of data. So it will be no more communication with the server and the paging, sorting and filtering (searching) will be implemented by jqGrid internally.

If you have not so many rows in the grid it could be good way, but you have to return all data at one. The data should be correctly sorted. If you want to implement sorting, paging and filtering on the server side you have to remove loadonce: true option.