0

を使用せずにサブグリッドにjsonデータを入力しようとしていますsubgridurl(これにより、各行が展開されるページが呼び出されます)。しかし、エラーが発生しています:"t.rows is undefined"(grid.base.js内)。コードは以下の通りです: 使用されるモジュールのバージョン:

  1. jquery-1.6.2.js
  2. jqGrid 3.3.2

前もって感謝します。

        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;
    }
4

1 に答える 1

0

「t.rows is undefined」というエラーは、通常、グリッドに間違った HTML フラグメントを使用していることを意味します。<div>たとえばの代わりに使用する<table>と、エラーが発生します。

さらに、現在の jqGrid バージョン 4.1.2 にアップグレードすることを強くお勧めします。jqGrid 3.3.2 を今日特に比較的新しいバージョンの jQuery 1.6.2 と一緒に使用すると、問題が発生する可能性があります。これは、新しいモーターに 30 年前のベンジンを使用しようとするようなものです。深刻な問題を受け取ることができます。

于 2011-09-20T21:52:39.790 に答える