2012-06-18 1 views
2

그리드 뒤에있는 데이터가 작동 중이며 그 결과가 FireBug 콘솔에 인쇄 된 것을 볼 수있는 것처럼 동적 트리 그리드를 표시 할 수 없었습니다. 그러나 그 중 어느 것도 ExtJS Tree Grid에 나타나지 않고, 저장소에 정적으로 설정된 루트 노드를 제외하고는 아무 것도 표시되지 않습니다.ExtJS 4.0.7 : 트리 그리드가 보이지 않습니다.

보기 :

Ext.define('TS.view.file.archives.raGrid', { 
    extend: 'Ext.tree.Panel', 
    alias: 'widget.ramaingridpanel', 

    id: 'raGrid', 
    autoScroll: true, 
    store: 'file.archives.Resources', 
    layout: { 
     type: 'hbox', 
     align: 'top', 
     pack: 'start' 
    }, 
    columns: [{ 
     xtype: 'treecolumn', 
     id: 'raGridResourceName', 
     flex: 2, 
     dataIndex: 'text', 
     width: 100, 
     hideable: false, 
     groupable: false, 
     text: 'Name', 
     editor: { 
      xtype: 'textfield' 
     } 
    }, { 
     xtype: 'templatecolumn', 
     id: 'raGridResourceIcon', 
     tpl: new Ext.XTemplate('<div id="{iconCls}" class="{iconCls}" role="presentation">&nbsp;</div>').html, 
     flex: 0.1, 
     dataIndex: 'iconCls', 
     hideable: false, 
     groupable: false, 
     editor: { 
      xtype: 'combobox', 
      store: Ext.data.StoreManager.lookup('file.archive.ResourceIcons') 
     } 
    }, { 
     xtype: 'datecolumn', 
     id: 'raGridDate', 
     flex: 1, 
     dataIndex: 'updated', 
     hideable: false, 
     groupable: false, 
     text: 'Updated' 
    }, { 
     xtype: 'gridcolumn', 
     id: 'raGridPurchasingUnit', 
     flex: 1, 
     dataIndex: 'purchasedUnit', 
     groupable: false, 
     text: 'Unit', 
     editor: { 
      xtype: 'textfield' 
     } 
    }, { 
     xtype: 'numbercolumn', 
     id: 'raGridCost', 
     flex: 1, 
     dataIndex: 'purchasedCost', 
     groupable: false, 
     text: 'Cost excl. VAT', 
     editor: { 
      xtype: 'textfield' 
     } 
    }, { 
     xtype: 'numbercolumn', 
     id: 'raGridDiscount', 
     dataIndex: 'purchasedDiscount', 
     flex: 1, 
     groupable: false, 
     text: 'Discount %', 
     editor: { 
      xtype: 'textfield' 
     } 
    }, { 
     xtype: 'gridcolumn', 
     id: 'raGridEstimatingUnit', 
     flex: 1, 
     dataIndex: 'estimateUnit', 
     groupable: false, 
     text: 'Unit', 
     editor: { 
      xtype: 'textfield' 
     } 
    }, { 
     xtype: 'numbercolumn', 
     id: 'raGridAddOn', 
     flex: 1, 
     dataIndex: 'profitAddOn', 
     groupable: false, 
     text: 'Mark-up %', 
     editor: { 
      xtype: 'textfield' 
     } 
    }, { 
     xtype: 'numbercolumn', 
     id: 'raGridLanded', 
     flex: 1, 
     dataIndex: 'landedCost', 
     groupable: false, 
     text: 'Landed cost', 
     editor: { 
      xtype: 'textfield' 
     } 
    }, { 
     xtype: 'numbercolumn', 
     id: 'raGridCostPrice', 
     flex: 1, 
     dataIndex: 'number', 
     groupable: false, 
     text: 'Costprice', 
     editor: { 
      xtype: 'textfield' 
     } 
    }, { 
     xtype: 'numbercolumn', 
     id: 'raGridUnitCorrelation', 
     flex: 1, 
     dataIndex: 'unitCorrelation', 
     groupable: false, 
     text: 'Prch./Est.', 
     editor: { 
      xtype: 'textfield' 
     } 
    }, { 
     xtype: 'numbercolumn', 
     id: 'raLeadTime', 
     flex: 1, 
     dataIndex: 'leadTime', 
     groupable: false, 
     text: 'Leadtime', 
     editor: { 
      xtype: 'textfield' 
     } 
    }, { 
     xtype: 'gridcolumn', 
     id: 'raGridClass', 
     flex: 1, 
     dataIndex: 'ResourceClassShortname', 
     groupable: false, 
     text: 'Class', 
     editor: { 
      xtype: 'textfield' 
     } 
    }, { 
     xtype: 'gridcolumn', 
     id: 'raGridSupplier', 
     flex: 1, 
     dataIndex: 'supplierName', 
     groupable: false, 
     text: 'Supplier', 
     editor: { 
      xtype: 'textfield' 
     } 
    }], 
    viewConfig: { 
     id: 'raGridView' 
    }, 
    plugins: [{ 
     ptype: 'rowediting', 
     autoCancel: false, 
     clicksToEdit: 2 
    }, { 
     ptype: 'gridviewdragdrop', 
     ddGroup: 'raDdGroup' 
    }] 
}); 

상점 :

Ext.define('TS.store.file.archives.Resources', { 
    extend: 'Ext.data.TreeStore', 
    alias: 'store.file.archives.Resources', 

    model: 'TS.model.file.archives.Resources', 
    autoLoad: false, 
    proxy: { 
     type: 'ajax', 
     url: 'index.php/ajax/resources/', 
     reader: { 
      type: 'json', 
      root: 'results', 
      successProperty: 'success', 
      totalProperty: 'total' 
     } 
    }, 
    root: { 
     text: 'Resources', 
     id: 'myResources', 
     expanded: true, 
     children: {} 
    } 
}); 

모델 :

Ext.define('TS.model.file.archives.Resources', { 
extend : 'Ext.data.Model', 
alias : 'model.file.archives.Resources', 

fields : [ { 
    name : 'id', 
    type : 'int' 
}, { 
    name : 'parent_id', 
    type : 'int' 
}, { 
    name : 'child_id', 
    type : 'int' 
}, { 
    name : 'text', 
    type : 'string' 
}, { 
    name : 'updated', 
    type : 'date' 
}, { 
    name : 'purchasedUnit', 
    type : 'string' 
}, { 
    name : 'purchasedCost', 
    type : 'double' 
}, { 
    name : 'purchasedDiscount', 
    type : 'double' 
}, { 
    name : 'estimateUnit', 
    type : 'string' 
}, { 
    name : 'profitAddOn', 
    type : 'string' 
}, { 
    name : 'addonManager', 
    type : 'string' 
}, { 
    name : 'landedCost', 
    type : 'double' 
}, { 
    name : 'unitCorrelation', 
    type : 'double' 
}, { 
    name : 'leadTime', 
    type : 'string' 
}, { 
    name : 'ResourceClassShortname', 
    type : 'string' 
}, { 
    name : 'supplierName', 
    type : 'string' 
}, { 
    name : 'iconCls', 
    type : 'string' 
}, { 
    name : 'ClientSessionId', 
    type : 'string' 
} ] 
}); 

JSON 데이터 :

({ 
    "success":"true", 
    "total":"1", 
    "results": 
    [{ 
     "id":0, 
     "parent_id":0, 
     "child_id":2, 
     "text":"Gravemaskiner", 
     "updated":1339079129, 
     "purchasedUnit":"", 
     "purchasedCost":0, 
     "purchasedDiscount":0, 
     "estimateUnit":"", 
     "profitAddOn":"", 
     "landedCost":0, 
     "unitCorrelation":0, 
     "leadTime":"", 
     "ResourceClassShortname":"", 
     "supplierName":"", 
     "iconCls":"iconFolder", 
     "leaf":false, 
     "children":... 
,

사람이 사용의 ExtJS 4.0.7


업데이트 좋을 것 내 코드,

G.

뭐가 잘못 됐는지 너무 친절 점을 될 경우 2012-06-

(19)는 많은 시험하고이 오류가 함께 할 수있는 뭔가를 갖고있는 것 같아요,하지만 난 무슨 뜻인지 모르겠어요 그것을 해결하는 방법 :

records[i] is undefined /extjs/ext-all-dev.js Line 88068

17,451,515,는 콘솔에 개체를 인쇄 한 그들은 명확하게 저장소에있는 데이터가 표시됩니다.


+0

을 나는 느낌이 수행하는 내 컨트롤러에 뭔가 빠져있다. 다른 사이트에서이 코드'settingsTreeStore.getRootNode(). appendChild (userTreeStore.getRootNode()). expand();를 찾았습니다. 어떻게하면 현재 컨트롤러에 추가 할 수 있습니까? 아마도 gridview의'afterload'를 실행하는 코드가 있을까요? – rnngau

+0

가능한 경우 최신 코드를 사용해야합니다. 4.0.7 짜증나기 –

+0

4.1.0에서 많은 오류가 발생했습니다. XTemplate 등을 할 무언가가 분명합니다. – rnngau

답변

0

엽차 지원은 다음 대답

// I used this: 
$result[$i] = $newArray; 

// To fix I had to use this to generate the JSON 
array_push($result,$newArray); 

그리고 :

I did notice on your original json, that it was wrapped in "()" which is incorrect.

1

독자의 필요 은과 같이 정의한다 :

reader : { 
    type : 'json', 
    root : 'children', 
    successProperty : 'success', 
    totalProperty : 'total' 
} 

그리고 당신의 JSON 루트 results에서 children로 변경해야합니다.

The reason the tree is not loading correctly is because the json invalid for the tree to digest.

문제는 JSON에 있었다 - 그것이 생성 방법 :

+0

json 루트 및 독자 정의가 변경되었지만 아직 작동하지 않습니다. – rnngau