Ext 下拉树
Ext.define('businesTreeModel', { extend : 'Ext.data.TreeModel', fields : [ { name : 'classification', mapping : 'classification' }, { name : 'catalog', mapping : 'catalog' }, { name : 'categories', mapping : 'categories' }, { name : 'isLeaf', mapping : 'isLeaf' }, { name : 'id', mapping : 'id' }], proxy : { type : 'ajax', api : { read : 'findTree.action' } } });
var businesTreeStore= Ext.create('Ext.data.TreeStore', { model : 'businesTreeModel', root : { name : 'root', expanded : true } });
var modifyMainStationWindow = Ext.create("Ext.window.Window", { title : "修改", layout:'fit', items : [ modifyMainStationPanel], closeAction : 'hide' });
var treePanel = Ext.create('Ext.tree.Panel', { store : businesWholeTreeStore, width : 300, layout : 'fit', region : 'west', hideHeaders : true, columns : [{ xtype : 'treecolumn', width : 300, dataIndex : 'name', flex : '1' }], tbar:[ { xtype : "button", tooltip : "添加目录", text:'添加目录', tooltipType : "title", icon : 'image/add.gif', handler : function() { var selected = treePanel.getSelectionModel().getSelection(); if(!(selected.length>0)){ }else{ var isLeaf=selected[0].data.isLeaf; if("false" == isLeaf){ Ext.Msg.alert("提示", "不能在子节点添加!"); return } } Ext.getCmp("DTisLeafId").setValue(true); addMainStationWindow.show(); } },{ xtype : "button", tooltip : "添加子节点", text:'添加子节点', tooltipType : "title", icon : 'image/add.gif', handler : function() { var selected = treePanel.getSelectionModel().getSelection(); if(!(selected.length>0)){ }else{ var isLeaf=selected[0].data.isLeaf; if("false"== isLeaf){ Ext.Msg.alert("提示", "不能在子节点添加!"); return } } Ext.getCmp("DTisLeafId").setValue(false); addMainStationWindow.show(); } },{ xtype : "button", tooltip : "删除", text:'删除', tooltipType : "title", icon : 'image/delete.gif', handler : function() { var selected = treePanel.getSelectionModel().getSelection(); if(!selected.length>0){ Ext.Msg.alert("提示", "请选择要删除的节点!"); return } Ext.Msg.confirm('确认', '是否确定删除?', function(btn) { if(btn=="yes"){ Ext.Ajax.request({ url : 'deleteNode.action', method : 'post', params : { 'classification.id' : selected[0].data.id }, success : function(response, options) { var o = Ext.JSON.decode(response.responseText); if(o.success==false){ }else{ var parent = selected[0].parentNode; parent.removeChild(selected[0]); treePanel.getSelectionModel().select(parent); } Ext.Msg.alert("提示", '删除成功!'); }, failure : function() { Ext.Msg.alert("提示", "系统忙!"); } }); } }); } },{ xtype : "button", tooltip : "修改", text:'修改', tooltipType : "title", icon : 'image/page_white_edit.png', handler : function() { var selected = treePanel.getSelectionModel().getSelection(); if(!selected.length>0){ Ext.Msg.alert("提示", "请选择要修改的节点!"); return } Ext.getCmp("modifyMainStationNameId").setValue(selected[0].data.name); modifyMainStationWindow.show(); } }], rootVisible : false, });
var addMainStationWindow = Ext.create("Ext.window.Window", { title : "添加", layout:'fit', items : [ addMainStationPanel], closeAction : 'hide' });