首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jqxgrid未加载数据

jqxgrid未加载数据
EN

Stack Overflow用户
提问于 2015-01-05 15:20:31
回答 1查看 134关注 0票数 0

我正在尝试从我的控制器获取数据。查询可以正常工作,但我似乎无法在视图中加载数据。如果有人能看到我的错误,我将不胜感激。

控制器

代码语言:javascript
复制
  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);
        }

视图

代码语言:javascript
复制
 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'}
                                ],

                            });
EN

回答 1

Stack Overflow用户

发布于 2015-01-05 15:40:27

代码语言:javascript
复制
   //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
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27775014

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档