2015-01-05 2 views
0

Я пытаюсь привести данные от своего контроллера. Запросы работают правильно, но я не могу загрузить данные в представление. Если кто-нибудь увидит мою ошибку, я буду признателен.jqxgrid не загружает данные

контроллер

public ActionResult GetItemList(int RRGroupID) 
     { 

      var item = ReportEngineHelper.GetReportingEngine(Session).Generate<ItemListQuery>(new Filter() 
      { 
       Item=new Item() 
       { 
        RRGroupID = RRGroupID, 

       } 
      }).ToQueryModel<ItemName>(); 
      var listItemName = new List<ItemName>(); 


      return Json(item, JsonRequestBehavior.AllowGet); 
     } 

вид

var detailsSource = 
          { 
            url: $.ajax({url: url, 
                type: "json", 
                data: {RRGroupID:RRGroupID}, 
                   }), 
            datatype: "json", 
           datafields: [{ name: "ItemID", type: "int" }, { name: "FullItemName" }], 
          }; 
          var detailsAdapter = new $.jqx.dataAdapter(detailsSource); 
          $("#jqxgrid").jqxGrid({ 
           source: detailsAdapter, 
           autoheight:true, 
           autowidth: true, 
           columns: [ 
          { text: 'Item Name', datafield: 'FullItemName', width: 200, editable: false }, 
          { text: 'Unit', width: 100, editable: true }, 
          { text: 'Beginning Balance', width: 180, editable: true }, 
          { text: 'Loss', width: 80, editable: true, cellsalign: 'right' }, 
          { text: 'Quantity Recieved', width: 90, editable: true, cellsalign: 'right'}, 
          { text: 'DOS', width: 100, editable: true, cellsalign: 'right' }, 
          { text: 'Requested Quantity', width: 100, editable: true, cellsalign: 'right'} 
           ], 

          }); 
+0

ли ваш Аякса ответ содержит какие-либо данные? вы можете проверить его в консоли разработчика ... –

+0

Кажется, что RRGroupID передан контроллеру. вот почему я использовал его так: – NewtoCodedUI

ответ

0
//this is your function build grid 
    function buildDetail(data){ 
     var detailsSource:{ 
       localdata:data, 
       datafields: [{ name: "ItemID", type: "int" }, { name: "FullItemName" }], 
       type:'json', 
      }; 
      var detailsAdapter = new $.jqx.dataAdapter(detailsSource); 
         $("#jqxgrid").jqxGrid({ 
          source: detailsAdapter, 
          autoheight:true, 
          autowidth: true, 
          columns: [ 
         { text: 'Item Name', datafield: 'FullItemName', width: 200, editable: false }, 
         { text: 'Unit', width: 100, editable: true }, 
         { text: 'Beginning Balance', width: 180, editable: true }, 
         { text: 'Loss', width: 80, editable: true, cellsalign: 'right' }, 
         { text: 'Quantity Recieved', width: 90, editable: true, cellsalign: 'right'}, 
         { text: 'DOS', width: 100, editable: true, cellsalign: 'right' }, 
         { text: 'Requested Quantity', width: 100, editable: true, cellsalign: 'right'} 
          ], 

         }); 
    } 


// now get your data with ajax then build grid. 
$(document).ready(function(){ 
    $.ajax({url: url, 
      type: "json", 
      data: {RRGroupID:RRGroupID}, 
      success:function(data){ 
       //now call your build function 
       buildDetail(data); 
      } 
     }); 
}) 

К таким образом, вы загрузить данные без использования jqx.ajax

+0

ничего не показывал в консоли – NewtoCodedUI

+0

Я думаю, что я нашел проблему .. думаю, что это может быть так: url: $ .ajax ({url: url, type: "json", данные: {RRGroupID: RRGroupID}, }), ....... не знаю, как его решить. – NewtoCodedUI

+0

Yess !! потому что вам не нужен метод $ .ajax. Отредактируйте его, как показано выше. –

Смежные вопросы