Ext.tree.TreePanel扩展

Ext.tree.TreePanel的扩展很简单,一棵树需要root节点,数据加载来源loder,

因此,只需要重写这两个属性就可以扩展一棵树

 

示例代码如下:

 

Ext.namespace("Ext.ux");

Ext.ux.MyTree = Ext.extend(Ext.tree.TreePanel, {
   animate: true,
   enableDD: false,
   border: false,
   rootVisible: true,
   autoScroll: true,
   height: 500,
   initComponent: function()
   {
    this.root = new Ext.tree.AsyncTreeNode({
       id: "root",
       text: "菜单树"
      });
    this.loader = new Ext.tree.TreeLoader({
       dataUrl: "BBM/getTree.action",
       listeners: {
        "beforeload": function(treeLoader, node)
        {
         treeLoader.baseParams.id = (node.id != "root"
           ? node.id
           : "");
        }
       }
      });
    Ext.ux.MyTree .superclass.initComponent.call(this);
   }
  })

Ext.reg("myTree", Ext.ux.MyTree );
/*Ext.onReady(function()
  {
   Ext.BLANK_IMAGE_URL = "../resources/images/s.gif";
   Ext.QuickTips.init();
   Ext.form.Field.prototype.msgTarget = "side";
   var viewport = new Ext.Viewport({
      layout: "fit",
      items: {
       id: "菜单树",
       region: "center",
       xtype: "myTree"
      }
     })
  })*/

你可能感兴趣的:(function,image,layout,url,扩展,border)