2014-03-01 203 views
0

我用json字符串創建一個jqgrid。就在一小時之前它正常工作。現在它不工作,我不明白這個錯誤。它也不顯示任何錯誤消息。JqGrid沒有顯示數據

public void ProcessRequest(HttpContext context) 
{ 
    string value = "{\"Table\":[{\"FLD_ID\":1,\"FLD_DATE\":\"17-02-2014 04:51:34 PM\",\"FLD_MOD_DATE\":\"17-02-2014 04:51:43 PM\",\"FLD_CNTRY_NAME\":\"DAFEDA\",\"FLD_CNTRY_CODE\":null,\"FLD_DESC\":\"VALUE\",\"FLD_STATUS\":1,\"CREATED_BY\":\"DAFEDA\"}],\"Table1\":[{\"DBSTATUS\":\"SUCCESS\"}]}"; 
    context.Response.Write(value); 
} 

    <script type="text/javascript"> 
        try { 
         jQuery.fn.center = function() { 
          this.css("position", "absolute"); 
          this.css("top", ($(window).height() - this.height())/2 + $(window).scrollTop() + "px"); 
          this.css("left", ($(window).width() - this.width())/2 + $(window).scrollLeft() + "px"); 
          return this; 
         } 

         var gwdth = $("#grd").width(); 
         jQuery("#JQCntryGrid").jqGrid({ 
          url: 'JQGridHandler.ashx', 
          datatype: "json", 
          width: gwdth, 
          height: 'auto', 
          colNames: ['Id', 'Date', 'Mod Date', 'Country Name', 'Country Code', 'Desc', 'Status', 'Created By'], 
          colModel: [ 
         { name: 'FLD_ID', index: 'FLD_ID', width: 20, stype: 'text' }, 
         { name: 'FLD_DATE', index: 'FLD_DATE', width: 150, stype: 'text', sortable: true, editable: false }, 
         { name: 'FLD_MOD_DATE', index: 'FLD_MOD_DATE', width: 60, editable: false }, 
         { name: 'FLD_CNTRY_NAME', index: 'FLD_USER_NAME', width: 150, editable: true, edittype: "text", editrules: { required: true} }, 
         { name: 'FLD_CNTRY_CODE', index: 'FLD_CNTRY_CODE', width: 120, editable: true, edittype: "text", editrules: { required: true} }, 
         { name: 'FLD_DESC', index: 'FLD_DESC', width: 130, editable: true, edittype: "text", editrules: { required: true} }, 
         { name: 'FLD_STATUS', index: 'FLD_STATUS', width: 100, editable: true, edittype: "select", editrules: { required: true} }, 
         { name: 'CREATED_BY', index: 'CREATED_BY', width: 130, sortable: true, editable: false }, 
         ],...... 

回答

3

您需要添加jsonReaderroot: "Table"來解決這個問題:

jsonReader: { 
    root: "Table", 
    repeatitems: false 
}, 

我建議你還用loadonce: truegridview: trueautoencode: true選項(請參閱文檔)。 width的設置可能可以替換爲autowidth: true的使用。

The demo顯示結果。