2014-10-22 28 views

回答

0

有没有这个功能在本机TreeView控件。你必须通过你自己来实现它。

Class('App', 'xui.Com',{ 
    Instance:{ 
     iniComponents : function(){ 
      // [[Code created by CrossUI RAD Tools 
      var host=this, children=[], append=function(child){children.push(child.get(0));}; 

      append(
       (new xui.UI.Pane()) 
       .setHost(host,"ctl_pane22") 
       .setLeft(80) 
       .setTop(30) 
       .setWidth(130) 
       .setHeight(140) 
      ); 

      host.ctl_pane22.append(
       (new xui.UI.TreeView()) 
       .setHost(host,"ctl_treeview9") 
       .setItems([{ 
        "id" : "node1", 
        "sub" : ["node11",{ 
         "id" : "node12", 
        },"node13","node14"], 
        "caption" : "node1" 
       },{ 
        "id" : "node2", 
        "sub" : ["node21","node22","node23","node24"], 
        "caption" : "node2" 
       }]) 
       .onDblclick("_ctl_treeview9_ondblclick") 
       ); 

      return children; 
      // ]]Code created by CrossUI RAD Tools 
     }, 
     _ctl_treeview9_ondblclick:function (profile, item, e, src){ 
      var tv=profile.boxing(), 
       source = profile.getSubNodeByItemId('ITEMCAPTION',item.id), 
       pos = source.offset(), 
       size = source.cssSize(); 

      var editor=new xui.UI.Input(); 
      editor.setWidth(size.width+20).setValue(item.caption); 
      editor.beforeUIValueSet(function(prf, ov, nv){ 
       tv.updateItem(item.id, {caption:nv}); 
       editor.destroy(); 
       root.setBlurTrigger("my_editor",null); 
       editor=null; 
      }); 
      xui('body').append(editor); 
      var root=editor.getRoot(); 
      root.popToTop(pos); 
      root.setBlurTrigger("my_editor",function(){ 
       editor.setUIValue(editor.getUIValue(),true); 
      }); 
      editor.activate(); 
      return false; 
     } 
    } 
});