X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/2e847cf21b8ab9d15fa167b315ca5b2fa92638fc..6a7e4474cba9d8be4b2ec445e10f1691f7277c50:/src/widgets/DataView.js diff --git a/src/widgets/DataView.js b/src/widgets/DataView.js index 7a537945..58c72a35 100644 --- a/src/widgets/DataView.js +++ b/src/widgets/DataView.js @@ -1,6 +1,6 @@ /*! - * Ext JS Library 3.1.1 - * Copyright(c) 2006-2010 Ext JS, LLC + * Ext JS Library 3.2.0 + * Copyright(c) 2006-2010 Ext JS, Inc. * licensing@extjs.com * http://www.extjs.com/license */ @@ -122,6 +122,12 @@ Ext.DataView = Ext.extend(Ext.BoxComponent, { * @cfg {Boolean} trackOver True to enable mouseenter and mouseleave events */ trackOver: false, + + /** + * @cfg {Boolean} blockRefresh Set this to true to ignore datachanged events on the bound store. This is useful if + * you wish to provide custom transition animations via a plugin (defaults to false) + */ + blockRefresh: false, //private last: false, @@ -252,7 +258,7 @@ Ext.DataView = Ext.extend(Ext.BoxComponent, { /** * Refreshes the view by reloading the data from the store and re-rendering the template. */ - refresh : function(){ + refresh : function() { this.clearSelections(false, true); var el = this.getTemplateTarget(); el.update(""); @@ -394,7 +400,7 @@ Ext.DataView = Ext.extend(Ext.BoxComponent, { this.store.destroy(); }else{ this.store.un("beforeload", this.onBeforeLoad, this); - this.store.un("datachanged", this.refresh, this); + this.store.un("datachanged", this.onDataChanged, this); this.store.un("add", this.onAdd, this); this.store.un("remove", this.onRemove, this); this.store.un("update", this.onUpdate, this); @@ -409,7 +415,7 @@ Ext.DataView = Ext.extend(Ext.BoxComponent, { store.on({ scope: this, beforeload: this.onBeforeLoad, - datachanged: this.refresh, + datachanged: this.onDataChanged, add: this.onAdd, remove: this.onRemove, update: this.onUpdate, @@ -421,6 +427,16 @@ Ext.DataView = Ext.extend(Ext.BoxComponent, { this.refresh(); } }, + + /** + * @private + * Calls this.refresh if this.blockRefresh is not true + */ + onDataChanged: function() { + if (this.blockRefresh !== true) { + this.refresh.apply(this, arguments); + } + }, /** * Returns the template node the passed child belongs to, or null if it doesn't belong to one. @@ -609,7 +625,7 @@ Ext.DataView = Ext.extend(Ext.BoxComponent, { /** * Returns true if the passed node is selected, else false. - * @param {HTMLElement/Number} node The node or node index to check + * @param {HTMLElement/Number/Ext.data.Record} node The node, node index or record to check * @return {Boolean} True if selected, else false */ isSelected : function(node){ @@ -618,7 +634,7 @@ Ext.DataView = Ext.extend(Ext.BoxComponent, { /** * Deselects a node. - * @param {HTMLElement/Number} node The node to deselect + * @param {HTMLElement/Number/Record} node The node, node index or record to deselect */ deselect : function(node){ if(this.isSelected(node)){ @@ -634,8 +650,8 @@ Ext.DataView = Ext.extend(Ext.BoxComponent, { /** * Selects a set of nodes. - * @param {Array/HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node, - * id of a template node or an array of any of those to select + * @param {Array/HTMLElement/String/Number/Ext.data.Record} nodeInfo An HTMLElement template node, index of a template node, + * id of a template node, record associated with a node or an array of any of those to select * @param {Boolean} keepExisting (optional) true to keep existing selections * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent */ @@ -683,7 +699,8 @@ Ext.DataView = Ext.extend(Ext.BoxComponent, { /** * Gets a template node. - * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node + * @param {HTMLElement/String/Number/Ext.data.Record} nodeInfo An HTMLElement template node, index of a template node, + * the id of a template node or the record associated with the node. * @return {HTMLElement} The node or null if it wasn't found */ getNode : function(nodeInfo){ @@ -691,6 +708,9 @@ Ext.DataView = Ext.extend(Ext.BoxComponent, { return document.getElementById(nodeInfo); }else if(Ext.isNumber(nodeInfo)){ return this.all.elements[nodeInfo]; + }else if(nodeInfo instanceof Ext.data.Record){ + var idx = this.store.indexOf(nodeInfo); + return this.all.elements[idx]; } return nodeInfo; }, @@ -720,7 +740,8 @@ Ext.DataView = Ext.extend(Ext.BoxComponent, { /** * Finds the index of the passed node. - * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node + * @param {HTMLElement/String/Number/Record} nodeInfo An HTMLElement template node, index of a template node, the id of a template node + * or a record associated with a node. * @return {Number} The index of the node or -1 */ indexOf : function(node){