Guest User

Untitled

a guest
Nov 18th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. Ext.define("ast.ast1949.util.TreeSelectorWin",{
  2. extend:"Ext.Window",
  3. initComponent:function(){
  4.  
  5. var tree=Ext.create("ast.ast1949.util.Tree",{
  6. rootCode:this.getRootCode(),
  7. treeModel:this.getTreeModel(),
  8. queryUrl:this.getQueryUrl(),
  9. rootexpanded:false
  10. });
  11.  
  12. var c={
  13. layout:"fit",
  14. items:[tree],
  15. buttons:[{
  16. text:"选择",
  17. iconCls:"accept16",
  18. scope:this,
  19. handler:function(btn,e){
  20. //tree选中项
  21. var model=tree.getSelectionModel().getLastSelected();
  22. this.callbackFn(model);
  23. }
  24. },{
  25. text:"关闭",
  26. iconCls:"close16",
  27. scope:this,
  28. handler:function(btn,e){
  29. this.close();
  30. }
  31. }]
  32. };
  33.  
  34. Ext.applyIf(this,c);
  35.  
  36. this.callParent();
  37. },
  38. rootCode:"",
  39. treeModel:"CategoryTreeModel",
  40. queryUrl:Context.ROOT+"/path/to/tree/node.htm",
  41. config:{
  42. queryUrl:null,
  43. rootCode:null,
  44. initCode:null,
  45. treeModel:"CategoryTreeModel"
  46. },
  47. callbackFn:function(nodeInterface){
  48. },
  49. initTree:function(codelength){
  50. var path="/";
  51. codelength=codelength||4;
  52. var pathArr=new Array();
  53. if(this.getInitCode()!=null && this.getInitCode().length>0){
  54. for(var i=this.getRootCode().length;i<=this.getInitCode().length;i=i+codelength){
  55. pathArr.push(this.getInitCode().substring(0,i));
  56. }
  57. }
  58. if(pathArr.length>0){
  59. path=path+pathArr.join("/");
  60. this.child("treepanel").selectPath(path, "id");
  61. }else{
  62. path=path+this.getRootCode();
  63. // this.child("treepanel").expandPath(path, "id");
  64. this.child("treepanel").getRootNode().expand();
  65. }
  66.  
  67. }
  68. });
Add Comment
Please, Sign In to add comment