首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >JqGrid - SubGrid未显示

JqGrid - SubGrid未显示
EN

Stack Overflow用户
提问于 2010-08-11 16:01:56
回答 2查看 3.1K关注 0票数 2

我在MVC项目中使用JqGrid-subGrid选项来获得嵌套的网格视图外观。我能够在父网格中填充数据,我已经启用子网格,并给出了用于弹出内部网格数据的subgrid地址。现在的问题是,子网格在页面执行时没有出现,不仅如此,subGridUrl:方法也没有被调用。有人能帮我找出背后的原因吗?下面是我的代码:

函数(文档).ready(jQuery () {

代码语言:javascript
运行
复制
     jQuery("#list").jqGrid({

         url: '/jqgrid/DynamicGridData/',

         datatype: 'json',

         mtype: 'GET',

         colNames: ['SurveyQnGrpId', 'SurveyQnGroup1'],

         colModel: [
              { name: 'SurveyQnGrpId', index: 'SurveyQnGrpId', width: 40, align: 'left' },

              { name: 'SurveyQnGroup1', index: 'SurveyQnGroup1', width: 400, align: 'left'}],

            pager: jQuery('#pager'),

         rowNum: 10,

         rowList: [5, 10, 20, 50],

         sortname: 'SurveyQnGrpId',

         sortorder: "SurveyQnGroup1",

         viewrecords: true,

         caption: 'My first grid',

            subGrid: true,

            subGridUrl: '/jqgrid/InnerGridData/',

         subGridModel: [
            {

                name: ['SurveyQnGrpId','SurveyQnId', 'SurveyQn', 'SurveyQnCategory', 'MandatoryQn','RadioOption3'],

                width: [10,10, 100, 10, 10,10],

                align: ['left', 'left', 'left', 'left'],

                params: ['SurveyQnGrpId']

            }]

     });
 });

提前谢谢你,安西

EN

回答 2

Stack Overflow用户

发布于 2011-01-11 23:32:58

我发现转储内置子网格并使用他们的" subgrid -as- grid“示例来动态插入一个全新的网格会更容易:

From their wiki:

代码语言:javascript
运行
复制
subGrid: true,
subGridRowExpanded: function(subgrid_id, row_id) {
// we pass two parameters
// subgrid_id is a id of the div tag created within a table
// the row_id is the id of the row
// If we want to pass additional parameters to the url we can use
// the method getRowData(row_id) - which returns associative array in type name-value
// here we can easy construct the following
   var subgrid_table_id;
   subgrid_table_id = subgrid_id+"_t";
   jQuery("#"+subgrid_id).html("<table id='"+subgrid_table_id+"' class='scroll'></table>");
   jQuery("#"+subgrid_table_id).jqGrid({
      url:"subgrid.php?q=2&id="+row_id,
      datatype: "xml",
      colNames: ['No','Item','Qty','Unit','Total'],
      colModel: [
        {name:"num",index:"num",width:80,key:true},
        {name:"item",index:"item",width:130},
        {name:"qty",index:"qty",width:80,align:"right"},
        {name:"unit",index:"unit",width:80,align:"right"},           
        {name:"total",index:"total",width:100,align:"right",sortable:false}
      ],
      height: 100%,
      rowNum:20,
      sortname: 'num',
      sortorder: "asc"
   });
票数 4
EN

Stack Overflow用户

发布于 2011-01-11 21:01:27

您需要添加

代码语言:javascript
运行
复制
subGrid: true,
        jsonReader : {
            root: "rows",
            page: "page",
            total: "total",
            records: "records",
            repeatitems: true,
            cell: "cell",
            id: "id",
            subgrid: {
                root: "rows",
                repeatitems: true,
                cell: "cell",
                id: "id"
            }
        },

您还需要下载新的jqgrid SRC目录并选择所有组件,因为我认为这些组件之间存在依赖关系。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3456437

复制
相关文章

相似问题

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