2011-03-17 7 views
0

행을 표시하지 않습니다 http://haacked.com/archive/2009/04/14/using-jquery-grid-with-asp.net-mvc.aspx있는 jqGrid 내가 기본적인있는 jqGrid 구축이 링크를 사용

이 내 코드 :

<script type="text/javascript"> 
jQuery(document).ready(function() { 
    jQuery("#list").jqGrid({ 
     url: '/Home/GridData/', 
     datatype: 'json', 
     mtype: 'GET', 
     colNames: ['ProductID', 'ProductName'], 
     colModel: [ 
     { name: 'ProductID', index: 'ProductID', width: 40, align: 'left' }, 
     { name: 'ProductName', index: 'ProductName', width: 40, align: 'left'}], 

     pager: jQuery('#pager'), 
     rowNum: 10, 
     rowList: [5, 10, 20, 50], 
     sortname: 'Id', 
     sortorder: "desc", 
     viewrecords: true, 
     imgpath: '/scripts/themes/coffee/images', 
     caption: 'My first grid' 
    }); 
}); 

public ActionResult GridData(string sidx, string sord, int page, int rows) 
    { 
     List<Product> listProducts = new List<Product>(){new Product(){ProductName = "koekies",ProductID = 1}, 
     new Product(){ProductName = "snoepjes",ProductID = 2}}; 
     return Json(listProducts, JsonRequestBehavior.AllowGet); 
    } 
+0

오류가 발생합니까? –

답변

0

하면 전체 게시물을 읽을나요 당신을 연결된? 그의 귀환 아들은 당신이 돌아 오는 것보다 훨씬 다른 것처럼 보입니다.

public ActionResult GridData(string sidx, string sord, int page, int rows) { 
    var jsonData = new { 
    total = 1, // we'll implement later 
    page = page, 
    records = 3, // implement later 
    rows = new[]{ 
     new {id = 1, cell = new[] {"1", "-7", "Is this a good question?"}}, 
     new {id = 2, cell = new[] {"2", "15", "Is this a blatant ripoff?"}}, 
     new {id = 3, cell = new[] {"3", "23", "Why is the sky blue?"}} 
    } 
    }; 
    return Json(jsonData, JsonRequestBehavior.AllowGet); 
} 

는 id 필드가 중요하다, jsgrid은 추가 행 번호를 알고 좋아한다.