2012-03-12 8 views
1

jqGrid 4.2.1を使用してtreeGridを設定しようとしていますが、いくつかの作業ビジュアルが表示されても構いませんが、展開の折りたたみは機能しません。アイコンのみがトグルしますが、グループは表示されたままです。jqGrid treeGrid Expand Collapse not working

{ 
    "total": 1, 
    "page": 1, 
    "records": 3, 
    "rows": [ 
     { 
      "i": 1, 
      "cell": [ 
       "", 
       "First", 
       "Description for First", 
       0, 
       "null", 
       false, 
       true, 
       true 
      ] 
     }, 
     { 
      "i": 2, 
      "cell": [ 
       "First", 
       "Second", 
       "Description for Second", 
       1, 
       "First", 
       false, 
       true, 
       true 
      ] 
     }, 
     { 
      "i": 3, 
      "cell": [ 
       "Second", 
       "Third", 
       "Description for Third", 
       2, 
       "Second", 
       false, 
       true, 
       true 
      ] 
     } 
    ] 
} 

としては、全てがそれを崩壊するノードをクリックするまで、視覚OKをooks前記(evreythingがexpandend示す)アイコントグル:JSONオブジェクトである

$("#list").jqGrid({ 
       treeGrid: true, 
       treeGridModel: 'adjacency', 
       ExpandColumn: 'BreakdownTag', 
       ExpandColClick: true, 
       url: '/AsyncData/Breakdown.ashx', 
       datatype: 'json', 
       mtype: 'GET', 
       colNames: ['Superior Tag', 'Breakdown Tag', 'Tag Description'], 
       colModel: [ 
        { name: 'SuperiorTag', id: 'SuperiorTag', index: 0, width: 250, 
hidden: true, align: 'left', sortable: false, classes: 'indeling', title: false }, 
        { name: 'BreakdownTag', id: 'BreakdownTag', index: 1, width: 250, 
align: 'left', sortable: false, classes: 'indeling', title: false, visible: false }, 
        { name: 'TagDescription', id: 'TagDescription', index: 2, width: 250, 
align: 'left', sortable: false, classes: 'indeling', title: false },], 
       rowNum: 20000, 
       viewrecords: true, 
       loadui: "disable", 
       emptyrecords: "Geen data gevonden...", 
       height: "100%", 
       treeIcons: { leaf: 'ui-icon-document-b' }, 
       loadonce: true, 
       hoverrows: false 
} 

      }); 

次のように

設定であります行は表示されたままです。 私はまあまあです...

答えて

1

JSONデータには2つのエラーがあり、JavaScriptコードには1つの小さなエラーがあります。

JSONダーダでは、アイテムIDとしてiの代わりにidを使用する必要があります。親要素を指定するには、(以下の例の代わりに、「第二」の2を使用)「BreakdownTag」列の値の代わりにidを使用する必要があります。

{ 
    "i": 3, 
    "cell": [ 
     "Second", 
     "Third", 
     "Description for Third", 
     2, 
     "Second", 
     false, 
     true, 
     true 
    ] 
} 

{ 
    "id": 3, 
    "cell": [ 
     "Second", 
     "Third", 
     "Description for Third", 
     2, 
     2, 
     false, 
     true, 
     true 
    ] 
} 
に固定する必要があります

マイナーJavaScriptエラーは、末尾に末尾のコンマを使用することです。colModel},]の組み合わせは}]に置き換えてください。

The demoは変更後も正しく機能します。

+0

これは、ソリューション全体と実際の例について、thanxの問題でした。よろしくお願いします。 – Arnoldiusss

+1

@Arnoldiusss:ようこそ!オランダは本当に私に近いです。私は以前に頻繁に訪れました。子供たちが焼かれた後は、ごくまれではありますが、おそらく家族全員でより頻繁に起こります。 – Oleg

+1

私はあなたが生まれたことを意味することを望むが、とにかく、再びthx。 – Arnoldiusss