2

我在 Extjs4 工作。我想使用复选框创建树视图以选择单个条目。我有 json 作为-

{"data":[{"Maincategory":"Main","maincategoryId":"1","Subcategory":{"subcategory":"GK","categoryId":"2"},{"subcategory":"History","categoryId":"3"},{"subcategory":"Geography","categoryId":"4"}]},{"Maincategory":"GK","maincategoryId":"2","Subcategory":[{"subcategory":"environment","categoryId":"5"}]},{"Maincategory":"History","maincategoryId":"3","Subcategory":[{"subcategory":"civics","categoryId":"7"}]},{"Maincategory":"Geography","maincategoryId":"4","Subcategory":[{"subcategory":"India","categoryId":"8"}]},{"Maincategory":"environment","maincategoryId":"5","Subcategory":[]}]}

我想创建这个 json 的树视图。那么如何在 extjs4 中创建带有复选框的树视图。

4

1 回答 1

0

将 Ext.selection.CheckboxModel 作为 selectionmodel 添加到树形面板

像这样的东西

{
 xtype: 'treepanel',
 style: 'margin-top: 10px;',
 itemId: 'searchresultstreepanel',
 flex: 1,
 autoScroll : true,
 store: me.searchResultsStore,
 rootVisible: false,
 loadMask: true,
 selModel: Ext.create('Ext.selection.CheckboxModel',{
     mode: 'MULTI'
 }),
 selType: 'treemodel',
 .....
于 2013-08-13T16:30:41.043 回答