0

私はさまざまなフォーラムに潜んでいて、この問題に関連するいくつかのスタックオーバーフローの質問を読んでいますが、私の人生では何が悪いのか理解できません.

次のコードを使用して、jqGrid treeGrid を生成しようとしています。

      jQuery("#structureBuilderTable").jqGrid({
        url: 'tree.json',
        datatype:'json',
        mtype:'GET',
        colNames: ["ID", "Description", "Total"],
        colModel: [
        {name:'id', index:'id', width: 1, hidden: true, key: true},
        {name:'desc', index:'desc', hidden: false, sortable: true},
        {name:'num', index:'num', hidden: false, sortable: true}
        ],
        treeGridModel:'adjacency',
        height:'auto',
        width:'500',
        pager:"#ptreegrid",
        treeGrid: true,
        ExpandColumn:'desc',
        ExpandColClick: true,
        caption:"TreeGrid Test"
      });

これは私の .json ファイルです (例として):

{
    "total": "1",
    "page": "1",
    "records": "2",
    "rows": [
           {"id": "1", "cell": ["1", "Super Item", "300", "0", "null", "false", "false"]},
           {"id": "2", "cell": ["2", "Item 1", "100", "1", "1", "false", "false"]},
           {"id": "3", "cell": ["3", "Sub Item 1", "50", "2", "2", "true", "true"]},
           {"id": "4", "cell": ["4", "Sub Item 2", "25", "2", "2", "false", "false"]},
           {"id": "5", "cell": ["5", "Sub-sub Item 1", "25", "3", "4", "true", "true"]},
           {"id": "6", "cell": ["6", "Sub Item 3", "25", "2", "2", "true", "true"]},
           {"id": "7", "cell": ["7", "Item 2", "200", "1", "1", "false", "false"]},
           {"id": "8", "cell": ["8", "Sub Item 1", "100", "2", "7", "false", "false"]},
           {"id": "9", "cell": ["9", "Sub-sub Item 1", "50", "3", "8", "true", "true"]},
           {"id": "10", "cell": ["10", "Sub-sub Item 2", "50", "3", "8", "true", "true"]},
           {"id": "11", "cell": ["11", "Sub Item 2", "100", "2", "7", "true", "true"]}
    ]
}

(これは、私がオンラインで見つけたガイドのほとんどの直接のコピーです)。

これで、グリッドが生成されましたが、データは含まれていません。javascriptファイルは「tree.json」と同じディレクトリにあるのですが、なぜか見つからないようです。デバッグ目的で以下を使用しました。

loadError: 関数 (xhr、ステータス、エラー) {アラート (ステータス + エラー)}

これは私が得たアラートです:

エラーはみつかりません

どんな助けでも大歓迎です。

4

1 に答える 1

0

JSON データと jqGrid に基づいて作成されたデモが、コード内のエラーを見つけるのに役立つことを願っています。おそらく、グリッドを作成するコードを の中に配置するのを忘れただけでしょうjQuery(function(){/**/});

1 つのヒント: いくつかのツリー ノードを私のデモのように展開して表示したい場合は、最後の列 (「展開された」非表示の列) に「true」の値を設定するだけでなく、「true」を追加する必要があります。ツリー グリッドの非表示の「ロード済み」列の値。詳細については、こちらこちらを参照してください。

于 2011-06-23T12:11:48.020 に答える