2012-10-09 85 views
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%' 
    }); 

這是我的jQuery網格。它的工作。但我無法瀏覽網格頁面。它僅查看第一頁。網格底部的arows不起作用。我不能去下一頁。任何人都可以幫我解決它嗎?瀏覽jqgrid的其他頁面(導航)

回答

0

我想你的代碼在行動@Url.Action("transaction")忽略pagerows其中jqGrid發送到服務器。您使用datatype: 'json'而不使用loadonce: true選項。所以你必須實現服務器端分頁的數據。

查看例如the answer的代碼示例,其中顯示瞭如何實現服務器端分頁,排序和搜索。

0

如果你不想實現服務器端分頁/排序,你可以使用loadonce:true選項。

但是,如果你想實現服務器端排序,首先你方法transaction應該準備好接受以下參數

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

如果您有jqGrid的工作,你會毫無疑問熟悉的默認參數前傳遞給任何ajax請求:「頁面」,「行」,「sidx」&「sord」。

這些參數分別對應於當前頁面,每頁記錄,排序列和排序順序。

這裏是一篇關於:How to use JqGrid with ASP.NET MVC的文章Philhaack還有另一篇關於here的文章。

This article,對於任何事情實現服務器端分頁和排序也會很有用。

相關問題