X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/7a654f8d43fdb43d78b63d90528bed6e86b608cc..refs/heads/master:/src/tree/View.js?ds=inline diff --git a/src/tree/View.js b/src/tree/View.js index 0e1be651..e07385b8 100644 --- a/src/tree/View.js +++ b/src/tree/View.js @@ -1,6 +1,19 @@ +/* + +This file is part of Ext JS 4 + +Copyright (c) 2011 Sencha Inc + +Contact: http://www.sencha.com/contact + +GNU General Public License Usage +This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html. + +If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact. + +*/ /** - * @class Ext.tree.View - * @extends Ext.view.Table + * Used as a view by {@link Ext.tree.Panel TreePanel}. */ Ext.define('Ext.tree.View', { extend: 'Ext.view.Table', @@ -13,15 +26,22 @@ Ext.define('Ext.tree.View', { checkboxSelector: '.' + Ext.baseCSSPrefix + 'tree-checkbox', expanderIconOverCls: Ext.baseCSSPrefix + 'tree-expander-over', + // Class to add to the node wrap element used to hold nodes when a parent is being + // collapsed or expanded. During the animation, UI interaction is forbidden by testing + // for an ancestor node with this class. + nodeAnimWrapCls: Ext.baseCSSPrefix + 'tree-animator-wrap', + blockRefresh: true, /** - * @cfg {Boolean} rootVisible false to hide the root node (defaults to true) + * @cfg {Boolean} rootVisible + * False to hide the root node. */ rootVisible: true, /** - * @cfg {Boolean} animate true to enable animated expand/collapse (defaults to the value of {@link Ext#enableFx Ext.enableFx}) + * @cfg {Boolean} animate + * True to enable animated expand/collapse (defaults to the value of {@link Ext#enableFx Ext.enableFx}) */ expandDuration: 250, @@ -54,7 +74,17 @@ Ext.define('Ext.tree.View', { me.animQueue = {}; me.callParent(arguments); }, - + + processUIEvent: function(e) { + // If the clicked node is part of an animation, ignore the click. + // This is because during a collapse animation, the associated Records + // will already have been removed from the Store, and the event is not processable. + if (e.getTarget('.' + this.nodeAnimWrapCls, this.el)) { + return false; + } + return this.callParent(arguments); + }, + onClear: function(){ this.store.removeAll(); }, @@ -70,7 +100,6 @@ Ext.define('Ext.tree.View', { onRender: function() { var me = this, - opts = {delegate: me.expanderSelector}, el; me.callParent(arguments); @@ -90,14 +119,20 @@ Ext.define('Ext.tree.View', { }, onCheckboxChange: function(e, t) { - var item = e.getTarget(this.getItemSelector(), this.getTargetEl()), - record, value; + var me = this, + item = e.getTarget(me.getItemSelector(), me.getTargetEl()); if (item) { - record = this.getRecord(item); - value = !record.get('checked'); - record.set('checked', value); - this.fireEvent('checkchange', record, value); + me.onCheckChange(me.getRecord(item)); + } + }, + + onCheckChange: function(record){ + var checked = record.get('checked'); + if (Ext.isBoolean(checked)) { + checked = !checked; + record.set('checked', checked); + this.fireEvent('checkchange', record, checked); } }, @@ -133,7 +168,7 @@ Ext.define('Ext.tree.View', { tag: 'tr', html: [ '