2012-03-12 1 views
1

jqGrid를 사용하여 treeGrid를 설정하기 위해 tryoing하는 중입니다. 일부 작품은 시각적으로 보이지만 축소 축소는 작동하지 않습니다. 아이콘 만 전환되지만 그룹은 계속 표시됩니다.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 
      ] 
     } 
    ] 
} 

로서 모두를 축소하는 노드를 클릭 할 때까지 육안 확인 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

JavaScript 코드에 JSON 데이터에는 2 개의 오류가 있고 사소한 오류가 있습니다.

JSON dada에서 항목 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

전체 솔루션과 작업 예제에 대해 그건 고맙습니다. 네덜란드 이웃들로부터 감사합니다! – Arnoldiusss

+1

@Arnoldiusss : 환영합니다! 네덜란드는 정말로 나에게 가깝다. 나는 자주 전에 그것을 방문했다. 아이들이 태워지면 - 더 드물지 만 나중에는 온 가족이 더 자주있을 것입니다. – Oleg

+1

나는 당신이 태어난 것을 의미하지만, 어쨌든, 다시는 당신이 희망하기를 바랍니다. – Arnoldiusss