首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jqGrid SubGrid非人口

jqGrid SubGrid非人口
EN

Stack Overflow用户
提问于 2011-09-20 13:39:44
回答 1查看 1.1K关注 0票数 0

我试图在不使用subgridurl的情况下使用json数据为子网格配置插件(因为这将为每行展开调用页面)。但是正在出错:"t.rows is undefined" (在grid.base.js中)。代码如下:所用模块的版本:

  1. jquery-1.6.2.js
  2. jqGrid 3.3.2

提前谢谢。

代码语言:javascript
复制
        jQuery(gridID).jqGrid({
            url: dataURL,
            datatype: "json",
            colNames: ['ID', 'FirstName', 'LastName', 'Address1', 'Address2', 'City', 'Country'],
            colModel: [
                    { name: 'id', width: 200, sortable: false },
                    { name: 'firstName', width: 200, sortable: false, editable: true, edittype: 'select', editoptions: { value: { 1: '1', 2: '2', 3: '3'}} },
                    { name: 'lastName', width: 200, sortable: false, hidden: true },
                    { name: 'address1', width: 200, sortable: false, hidden: true },
                    { name: 'address1', width: 200, sortable: false, hidden: true },
                    { name: 'city', width: 200, sortable: false, hidden: false},
                    { name: 'country', width: 200, sortable: false, hidden: false}
                ],
            rowNum: 10,
            rowList: [10, 20, 30],
            pager: '#pager2',
            sortname: 'id',
            viewrecords: true,
            sortorder: "desc",
            caption: "TEST",
            height: "400px",
            subGrid: true,

            subGridRowExpanded: function(subgrid_id, row_id) {
                subGridID = subgrid_id;
                jQuery("#" + subGridID).html("<div style='margin-left:415px'><table id='" + subGridID + "' class='scroll'><tr><td>Testing</td><td>Testing</td><td>Testing</td><td>Testing</td><td>Testing</td><td>Testing</td></tr></table></div>"); ;
                jQuery("#" + subGridID).jqGrid(
       {
           datatype: function(pdata) { getDataSubGrid(pdata); },
           colNames: ['ID', 'FirstName', 'LastName', 'Address1', 'Address2', 'City', 'Country'],,
            colModel: [
                    { name: 'id', width: 200, sortable: false },
                    { name: 'firstName', width: 200, sortable: false, editable: true, edittype: 'select', editoptions: { value: { 1: '1', 2: '2', 3: '3'}} },
                    { name: 'lastName', width: 200, sortable: false, hidden: true },
                    { name: 'address1', width: 200, sortable: false, hidden: true },
                    { name: 'address1', width: 200, sortable: false, hidden: true },
                    { name: 'city', width: 200, sortable: false, hidden: false},
                    { name: 'country', width: 200, sortable: false, hidden: false}
                ],
           height: 100,
           rowNum: 20,

           sortorder: "asc",
           height: '100%'
       });
            }

        });

        jQuery("#mygrid").jqGrid('#mygrid', '#pager2', { edit: false, add: false, del: false });
    }


    function getDataSubGrid(pData) {
        gridId = "#mygrid_t";
        $.ajax({
            type: 'GET',
            contentType: "application/json; charset=utf-8",
            url: myURL,//myurl would get json data from web service
            data: '{}',
            dataType: "json",
            success: function(data, textStatus) {


                ReceivedClientDataForSubGrid(getMain(data).rows);
            },
            error: function(data, textStatus) {
                alert('An error has occured retrieving data subgrid!');
            }
        });
    }


    function ReceivedClientDataForSubGrid(data) {
        var thegrid = $("#" + subGridID);
        if ($(thegrid).length == 0) alert('NOT EXISTS');

        thegrid.clearGridData();
        alert(data.length);//this shows 10 
        for (var i = 0; i < data.length; i++) {
        thegrid.addRowData(i + 1, data[i]);
        }
    }


    function getMain(dObj) {
        if (dObj.hasOwnProperty('d'))
            return dObj.d;
        else
            return dObj;
    }
EN

回答 1

Stack Overflow用户

发布于 2011-09-20 21:52:39

错误"t.rows是未定义的“通常意味着您在网格中使用了错误的HTML片段。例如,如果要使用<div>而不是<table>,则会出现错误。

此外,我严格建议您升级到当前的jqGrid版本4.1.2。今天,jqGrid 3.3.2的使用,特别是与相对较新的1.6.2版jQuery一起使用,可能会出现问题。它就像尝试使用30年的旧汽油在新的自动汽车。你可能会遇到严重的问题。

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

https://stackoverflow.com/questions/7486112

复制
相关文章

相似问题

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