check-tree.js
上传用户:shuoshiled
上传日期:2018-01-28
资源大小:10124k
文件大小:2k
源码类别:

中间件编程

开发平台:

JavaScript

  1. /*!
  2.  * Ext JS Library 3.0.0
  3.  * Copyright(c) 2006-2009 Ext JS, LLC
  4.  * licensing@extjs.com
  5.  * http://www.extjs.com/license
  6.  */
  7. Ext.onReady(function(){
  8.     var tree = new Ext.tree.TreePanel({
  9.         renderTo:'tree-div',
  10.         title: 'My Task List',
  11.         height: 300,
  12.         width: 400,
  13.         useArrows:true,
  14.         autoScroll:true,
  15.         animate:true,
  16.         enableDD:true,
  17.         containerScroll: true,
  18.         rootVisible: false,
  19.         frame: true,
  20.         root: {
  21.             nodeType: 'async'
  22.         },
  23.         
  24.         // auto create TreeLoader
  25.         dataUrl: 'check-nodes.json',
  26.         
  27.         listeners: {
  28.             'checkchange': function(node, checked){
  29.                 if(checked){
  30.                     node.getUI().addClass('complete');
  31.                 }else{
  32.                     node.getUI().removeClass('complete');
  33.                 }
  34.             }
  35.         },
  36.         
  37.         buttons: [{
  38.             text: 'Get Completed Tasks',
  39.             handler: function(){
  40.                 var msg = '', selNodes = tree.getChecked();
  41.                 Ext.each(selNodes, function(node){
  42.                     if(msg.length > 0){
  43.                         msg += ', ';
  44.                     }
  45.                     msg += node.text;
  46.                 });
  47.                 Ext.Msg.show({
  48.                     title: 'Completed Tasks', 
  49.                     msg: msg.length > 0 ? msg : 'None',
  50.                     icon: Ext.Msg.INFO,
  51.                     minWidth: 200,
  52.                     buttons: Ext.Msg.OK
  53.                 });
  54.             }
  55.         }]
  56.     });
  57.     tree.getRootNode().expand(true);
  58. });