/*!
- * Ext JS Library 3.0.0
- * Copyright(c) 2006-2009 Ext JS, LLC
+ * Ext JS Library 3.2.0
+ * Copyright(c) 2006-2010 Ext JS, Inc.
* licensing@extjs.com
* http://www.extjs.com/license
*/
* @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,
"click",
/**
* @event mouseenter
- * Fires when the mouse enters a template node. trackOver:true or an overCls must be set to enable this event.
+ * Fires when the mouse enters a template node. trackOver:true or an overClass must be set to enable this event.
* @param {Ext.DataView} this
* @param {Number} index The index of the target node
* @param {HTMLElement} node The target node
"mouseenter",
/**
* @event mouseleave
- * Fires when the mouse leaves a template node. trackOver:true or an overCls must be set to enable this event.
+ * Fires when the mouse leaves a template node. trackOver:true or an overClass must be set to enable this event.
* @param {Ext.DataView} this
* @param {Number} index The index of the target node
* @param {HTMLElement} node The target node
/**
* 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("");
// private
onUpdate : function(ds, record){
var index = this.store.indexOf(record);
- var sel = this.isSelected(index);
- var original = this.all.elements[index];
- var node = this.bufferRender([record], index)[0];
-
- this.all.replaceElement(index, node, true);
- if(sel){
- this.selected.replaceElement(original, node);
- this.all.item(index).addClass(this.selectedClass);
+ if(index > -1){
+ var sel = this.isSelected(index);
+ var original = this.all.elements[index];
+ var node = this.bufferRender([record], index)[0];
+
+ this.all.replaceElement(index, node, true);
+ if(sel){
+ this.selected.replaceElement(original, node);
+ this.all.item(index).addClass(this.selectedClass);
+ }
+ this.updateIndexes(index, index);
}
- this.updateIndexes(index, index);
},
// private
*/
bindStore : function(store, initial){
if(!initial && this.store){
- this.store.un("beforeload", this.onBeforeLoad, this);
- this.store.un("datachanged", this.refresh, this);
- this.store.un("add", this.onAdd, this);
- this.store.un("remove", this.onRemove, this);
- this.store.un("update", this.onUpdate, this);
- this.store.un("clear", this.refresh, this);
if(store !== this.store && this.store.autoDestroy){
this.store.destroy();
+ }else{
+ this.store.un("beforeload", this.onBeforeLoad, 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);
+ this.store.un("clear", this.refresh, this);
+ }
+ if(!store){
+ this.store = null;
}
}
if(store){
store.on({
scope: this,
beforeload: this.onBeforeLoad,
- datachanged: this.refresh,
+ datachanged: this.onDataChanged,
add: this.onAdd,
remove: this.onRemove,
update: this.onUpdate,
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.
/**
* 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){
/**
* 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)){
/**
* 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
*/
/**
* 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){
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;
},
/**
* 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){
},
onDestroy : function(){
+ this.all.clear();
+ this.selected.clear();
Ext.DataView.superclass.onDestroy.call(this);
this.bindStore(null);
}
*/
Ext.DataView.prototype.setStore = Ext.DataView.prototype.bindStore;
-Ext.reg('dataview', Ext.DataView);/**\r
- * @class Ext.ListView\r
- * @extends Ext.DataView\r
- * <p>Ext.ListView is a fast and light-weight implentation of a\r
- * {@link Ext.grid.GridPanel Grid} like view with the following characteristics:</p>\r
- * <div class="mdetail-params"><ul>\r
- * <li>resizable columns</li>\r
- * <li>selectable</li>\r
- * <li>column widths are initially proportioned by percentage based on the container\r
- * width and number of columns</li>\r
- * <li>uses templates to render the data in any required format</li>\r
- * <li>no horizontal scrolling</li>\r
- * <li>no editing</li>\r
- * </ul></div>\r
- * <p>Example usage:</p>\r
- * <pre><code>\r
-// consume JSON of this form:\r
-{\r
- "images":[\r
- {\r
- "name":"dance_fever.jpg",\r
- "size":2067,\r
- "lastmod":1236974993000,\r
- "url":"images\/thumbs\/dance_fever.jpg"\r
- },\r
- {\r
- "name":"zack_sink.jpg",\r
- "size":2303,\r
- "lastmod":1236974993000,\r
- "url":"images\/thumbs\/zack_sink.jpg"\r
- }\r
- ]\r
-} \r
-var store = new Ext.data.JsonStore({\r
- url: 'get-images.php',\r
- root: 'images',\r
- fields: [\r
- 'name', 'url',\r
- {name:'size', type: 'float'},\r
- {name:'lastmod', type:'date', dateFormat:'timestamp'}\r
- ]\r
-});\r
-store.load();\r
-\r
-var listView = new Ext.ListView({\r
- store: store,\r
- multiSelect: true,\r
- emptyText: 'No images to display',\r
- reserveScrollOffset: true,\r
- columns: [{\r
- header: 'File',\r
- width: .5,\r
- dataIndex: 'name'\r
- },{\r
- header: 'Last Modified',\r
- width: .35, \r
- dataIndex: 'lastmod',\r
- tpl: '{lastmod:date("m-d h:i a")}'\r
- },{\r
- header: 'Size',\r
- dataIndex: 'size',\r
- tpl: '{size:fileSize}', // format using Ext.util.Format.fileSize()\r
- align: 'right'\r
- }]\r
-});\r
-\r
-// put it in a Panel so it looks pretty\r
-var panel = new Ext.Panel({\r
- id:'images-view',\r
- width:425,\r
- height:250,\r
- collapsible:true,\r
- layout:'fit',\r
- title:'Simple ListView <i>(0 items selected)</i>',\r
- items: listView\r
-});\r
-panel.render(document.body);\r
-\r
-// little bit of feedback\r
-listView.on('selectionchange', function(view, nodes){\r
- var l = nodes.length;\r
- var s = l != 1 ? 's' : '';\r
- panel.setTitle('Simple ListView <i>('+l+' item'+s+' selected)</i>');\r
-});\r
- * </code></pre>\r
- * @constructor\r
- * @param {Object} config\r
- * @xtype listview\r
- */\r
-Ext.ListView = Ext.extend(Ext.DataView, {\r
- /**\r
- * Set this property to <tt>true</tt> to disable the header click handler disabling sort\r
- * (defaults to <tt>false</tt>).\r
- * @type Boolean\r
- * @property disableHeaders\r
- */\r
- /**\r
- * @cfg {Boolean} hideHeaders\r
- * <tt>true</tt> to hide the {@link #internalTpl header row} (defaults to <tt>false</tt> so\r
- * the {@link #internalTpl header row} will be shown).\r
- */\r
- /**\r
- * @cfg {String} itemSelector\r
- * Defaults to <tt>'dl'</tt> to work with the preconfigured <b><tt>{@link Ext.DataView#tpl tpl}</tt></b>.\r
- * This setting specifies the CSS selector (e.g. <tt>div.some-class</tt> or <tt>span:first-child</tt>)\r
- * that will be used to determine what nodes the ListView will be working with. \r
- */\r
- itemSelector: 'dl',\r
- /**\r
- * @cfg {String} selectedClass The CSS class applied to a selected row (defaults to\r
- * <tt>'x-list-selected'</tt>). An example overriding the default styling:\r
- <pre><code>\r
- .x-list-selected {background-color: yellow;}\r
- </code></pre>\r
- * @type String\r
- */\r
- selectedClass:'x-list-selected',\r
- /**\r
- * @cfg {String} overClass The CSS class applied when over a row (defaults to\r
- * <tt>'x-list-over'</tt>). An example overriding the default styling:\r
- <pre><code>\r
- .x-list-over {background-color: orange;}\r
- </code></pre>\r
- * @type String\r
- */\r
- overClass:'x-list-over',\r
- /**\r
- * @cfg {Boolean} reserveScrollOffset\r
- * By default will defer accounting for the configured <b><tt>{@link #scrollOffset}</tt></b>\r
- * for 10 milliseconds. Specify <tt>true</tt> to account for the configured\r
- * <b><tt>{@link #scrollOffset}</tt></b> immediately.\r
- */\r
- /**\r
- * @cfg {Number} scrollOffset The amount of space to reserve for the scrollbar (defaults to\r
- * <tt>19</tt> pixels)\r
- */\r
- scrollOffset : 19,\r
- /**\r
- * @cfg {Boolean/Object} columnResize\r
- * Specify <tt>true</tt> or specify a configuration object for {@link Ext.ListView.ColumnResizer}\r
- * to enable the columns to be resizable (defaults to <tt>true</tt>).\r
- */\r
- columnResize: true,\r
- /**\r
- * @cfg {Array} columns An array of column configuration objects, for example:\r
- * <pre><code>\r
-{\r
- align: 'right',\r
- dataIndex: 'size',\r
- header: 'Size',\r
- tpl: '{size:fileSize}',\r
- width: .35\r
-}\r
- * </code></pre> \r
- * Acceptable properties for each column configuration object are:\r
- * <div class="mdetail-params"><ul>\r
- * <li><b><tt>align</tt></b> : String<div class="sub-desc">Set the CSS text-align property\r
- * of the column. Defaults to <tt>'left'</tt>.</div></li>\r
- * <li><b><tt>dataIndex</tt></b> : String<div class="sub-desc">See {@link Ext.grid.Column}.\r
- * {@link Ext.grid.Column#dataIndex dataIndex} for details.</div></li>\r
- * <li><b><tt>header</tt></b> : String<div class="sub-desc">See {@link Ext.grid.Column}.\r
- * {@link Ext.grid.Column#header header} for details.</div></li>\r
- * <li><b><tt>tpl</tt></b> : String<div class="sub-desc">Specify a string to pass as the\r
- * configuration string for {@link Ext.XTemplate}. By default an {@link Ext.XTemplate}\r
- * will be implicitly created using the <tt>dataIndex</tt>.</div></li>\r
- * <li><b><tt>width</tt></b> : Number<div class="sub-desc">Percentage of the container width\r
- * this column should be allocated. Columns that have no width specified will be\r
- * allocated with an equal percentage to fill 100% of the container width. To easily take\r
- * advantage of the full container width, leave the width of at least one column undefined.\r
- * Note that if you do not want to take up the full width of the container, the width of\r
- * every column needs to be explicitly defined.</div></li>\r
- * </ul></div>\r
- */\r
- /**\r
- * @cfg {Boolean/Object} columnSort\r
- * Specify <tt>true</tt> or specify a configuration object for {@link Ext.ListView.Sorter}\r
- * to enable the columns to be sortable (defaults to <tt>true</tt>).\r
- */\r
- columnSort: true,\r
- /**\r
- * @cfg {String/Array} internalTpl\r
- * The template to be used for the header row. See {@link #tpl} for more details.\r
- */\r
-\r
- initComponent : function(){\r
- if(this.columnResize){\r
- this.colResizer = new Ext.ListView.ColumnResizer(this.colResizer);\r
- this.colResizer.init(this);\r
- }\r
- if(this.columnSort){\r
- this.colSorter = new Ext.ListView.Sorter(this.columnSort);\r
- this.colSorter.init(this);\r
- }\r
- if(!this.internalTpl){\r
- this.internalTpl = new Ext.XTemplate(\r
- '<div class="x-list-header"><div class="x-list-header-inner">',\r
- '<tpl for="columns">',\r
- '<div style="width:{width}%;text-align:{align};"><em unselectable="on" id="',this.id, '-xlhd-{#}">',\r
- '{header}',\r
- '</em></div>',\r
- '</tpl>',\r
- '<div class="x-clear"></div>',\r
- '</div></div>',\r
- '<div class="x-list-body"><div class="x-list-body-inner">',\r
- '</div></div>'\r
- );\r
- }\r
- if(!this.tpl){\r
- this.tpl = new Ext.XTemplate(\r
- '<tpl for="rows">',\r
- '<dl>',\r
- '<tpl for="parent.columns">',\r
- '<dt style="width:{width}%;text-align:{align};"><em unselectable="on">',\r
- '{[values.tpl.apply(parent)]}',\r
- '</em></dt>',\r
- '</tpl>',\r
- '<div class="x-clear"></div>',\r
- '</dl>',\r
- '</tpl>'\r
- );\r
- };\r
- var cs = this.columns, allocatedWidth = 0, colsWithWidth = 0, len = cs.length;\r
- for(var i = 0; i < len; i++){\r
- var c = cs[i];\r
- if(!c.tpl){\r
- c.tpl = new Ext.XTemplate('{' + c.dataIndex + '}');\r
- }else if(Ext.isString(c.tpl)){\r
- c.tpl = new Ext.XTemplate(c.tpl);\r
- }\r
- c.align = c.align || 'left';\r
- if(Ext.isNumber(c.width)){\r
- c.width *= 100;\r
- allocatedWidth += c.width;\r
- colsWithWidth++;\r
- }\r
- }\r
- // auto calculate missing column widths\r
- if(colsWithWidth < len){\r
- var remaining = len - colsWithWidth;\r
- if(allocatedWidth < 100){\r
- var perCol = ((100-allocatedWidth) / remaining);\r
- for(var j = 0; j < len; j++){\r
- var c = cs[j];\r
- if(!Ext.isNumber(c.width)){\r
- c.width = perCol;\r
- }\r
- }\r
- }\r
- }\r
- Ext.ListView.superclass.initComponent.call(this);\r
- },\r
-\r
- onRender : function(){\r
- Ext.ListView.superclass.onRender.apply(this, arguments);\r
-\r
- this.internalTpl.overwrite(this.el, {columns: this.columns});\r
- \r
- this.innerBody = Ext.get(this.el.dom.childNodes[1].firstChild);\r
- this.innerHd = Ext.get(this.el.dom.firstChild.firstChild);\r
-\r
- if(this.hideHeaders){\r
- this.el.dom.firstChild.style.display = 'none';\r
- }\r
- },\r
-\r
- getTemplateTarget : function(){\r
- return this.innerBody;\r
- },\r
-\r
- /**\r
- * <p>Function which can be overridden which returns the data object passed to this\r
- * view's {@link #tpl template} to render the whole ListView. The returned object \r
- * shall contain the following properties:</p>\r
- * <div class="mdetail-params"><ul>\r
- * <li><b>columns</b> : String<div class="sub-desc">See <tt>{@link #columns}</tt></div></li>\r
- * <li><b>rows</b> : String<div class="sub-desc">See\r
- * <tt>{@link Ext.DataView}.{@link Ext.DataView#collectData collectData}</div></li>\r
- * </ul></div>\r
- * @param {Array} records An Array of {@link Ext.data.Record}s to be rendered into the DataView.\r
- * @param {Number} startIndex the index number of the Record being prepared for rendering.\r
- * @return {Object} A data object containing properties to be processed by a repeating\r
- * XTemplate as described above.\r
- */\r
- collectData : function(){\r
- var rs = Ext.ListView.superclass.collectData.apply(this, arguments);\r
- return {\r
- columns: this.columns,\r
- rows: rs\r
- }\r
- },\r
-\r
- verifyInternalSize : function(){\r
- if(this.lastSize){\r
- this.onResize(this.lastSize.width, this.lastSize.height);\r
- }\r
- },\r
-\r
- // private\r
- onResize : function(w, h){\r
- var bd = this.innerBody.dom;\r
- var hd = this.innerHd.dom\r
- if(!bd){\r
- return;\r
- }\r
- var bdp = bd.parentNode;\r
- if(Ext.isNumber(w)){\r
- var sw = w - this.scrollOffset;\r
- if(this.reserveScrollOffset || ((bdp.offsetWidth - bdp.clientWidth) > 10)){\r
- bd.style.width = sw + 'px';\r
- hd.style.width = sw + 'px';\r
- }else{\r
- bd.style.width = w + 'px';\r
- hd.style.width = w + 'px';\r
- setTimeout(function(){\r
- if((bdp.offsetWidth - bdp.clientWidth) > 10){\r
- bd.style.width = sw + 'px';\r
- hd.style.width = sw + 'px';\r
- }\r
- }, 10);\r
- }\r
- }\r
- if(Ext.isNumber(h == 'number')){\r
- bdp.style.height = (h - hd.parentNode.offsetHeight) + 'px';\r
- }\r
- },\r
-\r
- updateIndexes : function(){\r
- Ext.ListView.superclass.updateIndexes.apply(this, arguments);\r
- this.verifyInternalSize();\r
- },\r
-\r
- findHeaderIndex : function(hd){\r
- hd = hd.dom || hd;\r
- var pn = hd.parentNode, cs = pn.parentNode.childNodes;\r
- for(var i = 0, c; c = cs[i]; i++){\r
- if(c == pn){\r
- return i;\r
- }\r
- }\r
- return -1;\r
- },\r
-\r
- setHdWidths : function(){\r
- var els = this.innerHd.dom.getElementsByTagName('div');\r
- for(var i = 0, cs = this.columns, len = cs.length; i < len; i++){\r
- els[i].style.width = cs[i].width + '%';\r
- }\r
- }\r
-});\r
-\r
-Ext.reg('listview', Ext.ListView);/**\r
- * @class Ext.ListView.ColumnResizer\r
- * @extends Ext.util.Observable\r
- * <p>Supporting Class for Ext.ListView.</p>\r
- * @constructor\r
- * @param {Object} config\r
- */\r
-Ext.ListView.ColumnResizer = Ext.extend(Ext.util.Observable, {\r
- /**\r
- * @cfg {Number} minPct The minimum percentage to allot for any column (defaults to <tt>.05</tt>)\r
- */\r
- minPct: .05,\r
-\r
- constructor: function(config){\r
- Ext.apply(this, config);\r
- Ext.ListView.ColumnResizer.superclass.constructor.call(this);\r
- },\r
- init : function(listView){\r
- this.view = listView;\r
- listView.on('render', this.initEvents, this);\r
- },\r
-\r
- initEvents : function(view){\r
- view.mon(view.innerHd, 'mousemove', this.handleHdMove, this);\r
- this.tracker = new Ext.dd.DragTracker({\r
- onBeforeStart: this.onBeforeStart.createDelegate(this),\r
- onStart: this.onStart.createDelegate(this),\r
- onDrag: this.onDrag.createDelegate(this),\r
- onEnd: this.onEnd.createDelegate(this),\r
- tolerance: 3,\r
- autoStart: 300\r
- });\r
- this.tracker.initEl(view.innerHd);\r
- view.on('beforedestroy', this.tracker.destroy, this.tracker);\r
- },\r
-\r
- handleHdMove : function(e, t){\r
- var hw = 5;\r
- var x = e.getPageX();\r
- var hd = e.getTarget('em', 3, true);\r
- if(hd){\r
- var r = hd.getRegion();\r
- var ss = hd.dom.style;\r
- var pn = hd.dom.parentNode;\r
-\r
- if(x - r.left <= hw && pn != pn.parentNode.firstChild){\r
- this.activeHd = Ext.get(pn.previousSibling.firstChild);\r
- ss.cursor = Ext.isWebKit ? 'e-resize' : 'col-resize';\r
- } else if(r.right - x <= hw && pn != pn.parentNode.lastChild.previousSibling){\r
- this.activeHd = hd;\r
- ss.cursor = Ext.isWebKit ? 'w-resize' : 'col-resize';\r
- } else{\r
- delete this.activeHd;\r
- ss.cursor = '';\r
- }\r
- }\r
- },\r
-\r
- onBeforeStart : function(e){\r
- this.dragHd = this.activeHd;\r
- return !!this.dragHd;\r
- },\r
-\r
- onStart: function(e){\r
- this.view.disableHeaders = true;\r
- this.proxy = this.view.el.createChild({cls:'x-list-resizer'});\r
- this.proxy.setHeight(this.view.el.getHeight());\r
-\r
- var x = this.tracker.getXY()[0];\r
- var w = this.view.innerHd.getWidth();\r
-\r
- this.hdX = this.dragHd.getX();\r
- this.hdIndex = this.view.findHeaderIndex(this.dragHd);\r
-\r
- this.proxy.setX(this.hdX);\r
- this.proxy.setWidth(x-this.hdX);\r
-\r
- this.minWidth = w*this.minPct;\r
- this.maxWidth = w - (this.minWidth*(this.view.columns.length-1-this.hdIndex));\r
- },\r
-\r
- onDrag: function(e){\r
- var cursorX = this.tracker.getXY()[0];\r
- this.proxy.setWidth((cursorX-this.hdX).constrain(this.minWidth, this.maxWidth));\r
- },\r
-\r
- onEnd: function(e){\r
- var nw = this.proxy.getWidth();\r
- this.proxy.remove();\r
-\r
- var index = this.hdIndex;\r
- var vw = this.view, cs = vw.columns, len = cs.length;\r
- var w = this.view.innerHd.getWidth(), minPct = this.minPct * 100;\r
-\r
- var pct = Math.ceil((nw*100) / w);\r
- var diff = cs[index].width - pct;\r
- var each = Math.floor(diff / (len-1-index));\r
- var mod = diff - (each * (len-1-index));\r
-\r
- for(var i = index+1; i < len; i++){\r
- var cw = cs[i].width + each;\r
- var ncw = Math.max(minPct, cw);\r
- if(cw != ncw){\r
- mod += cw - ncw;\r
- }\r
- cs[i].width = ncw;\r
- }\r
- cs[index].width = pct;\r
- cs[index+1].width += mod;\r
- delete this.dragHd;\r
- this.view.setHdWidths();\r
- this.view.refresh();\r
- setTimeout(function(){\r
- vw.disableHeaders = false;\r
- }, 100);\r
- }\r
-});/**\r
- * @class Ext.ListView.Sorter\r
- * @extends Ext.util.Observable\r
- * <p>Supporting Class for Ext.ListView.</p>\r
- * @constructor\r
- * @param {Object} config\r
- */\r
-Ext.ListView.Sorter = Ext.extend(Ext.util.Observable, {\r
- /**\r
- * @cfg {Array} sortClasses\r
- * The CSS classes applied to a header when it is sorted. (defaults to <tt>["sort-asc", "sort-desc"]</tt>)\r
- */\r
- sortClasses : ["sort-asc", "sort-desc"],\r
-\r
- constructor: function(config){\r
- Ext.apply(this, config);\r
- Ext.ListView.Sorter.superclass.constructor.call(this);\r
- },\r
-\r
- init : function(listView){\r
- this.view = listView;\r
- listView.on('render', this.initEvents, this);\r
- },\r
-\r
- initEvents : function(view){\r
- view.mon(view.innerHd, 'click', this.onHdClick, this);\r
- view.innerHd.setStyle('cursor', 'pointer');\r
- view.mon(view.store, 'datachanged', this.updateSortState, this);\r
- this.updateSortState.defer(10, this, [view.store]);\r
- },\r
-\r
- updateSortState : function(store){\r
- var state = store.getSortState();\r
- if(!state){\r
- return;\r
- }\r
- this.sortState = state;\r
- var cs = this.view.columns, sortColumn = -1;\r
- for(var i = 0, len = cs.length; i < len; i++){\r
- if(cs[i].dataIndex == state.field){\r
- sortColumn = i;\r
- break;\r
- }\r
- }\r
- if(sortColumn != -1){\r
- var sortDir = state.direction;\r
- this.updateSortIcon(sortColumn, sortDir);\r
- }\r
- },\r
-\r
- updateSortIcon : function(col, dir){\r
- var sc = this.sortClasses;\r
- var hds = this.view.innerHd.select('em').removeClass(sc);\r
- hds.item(col).addClass(sc[dir == "DESC" ? 1 : 0]);\r
- },\r
-\r
- onHdClick : function(e){\r
- var hd = e.getTarget('em', 3);\r
- if(hd && !this.view.disableHeaders){\r
- var index = this.view.findHeaderIndex(hd);\r
- this.view.store.sort(this.view.columns[index].dataIndex);\r
- }\r
- }\r
-});
\ No newline at end of file
+Ext.reg('dataview', Ext.DataView);
+/**
+ * @class Ext.list.ListView
+ * @extends Ext.DataView
+ * <p>Ext.list.ListView is a fast and light-weight implentation of a
+ * {@link Ext.grid.GridPanel Grid} like view with the following characteristics:</p>
+ * <div class="mdetail-params"><ul>
+ * <li>resizable columns</li>
+ * <li>selectable</li>
+ * <li>column widths are initially proportioned by percentage based on the container
+ * width and number of columns</li>
+ * <li>uses templates to render the data in any required format</li>
+ * <li>no horizontal scrolling</li>
+ * <li>no editing</li>
+ * </ul></div>
+ * <p>Example usage:</p>
+ * <pre><code>
+// consume JSON of this form:
+{
+ "images":[
+ {
+ "name":"dance_fever.jpg",
+ "size":2067,
+ "lastmod":1236974993000,
+ "url":"images\/thumbs\/dance_fever.jpg"
+ },
+ {
+ "name":"zack_sink.jpg",
+ "size":2303,
+ "lastmod":1236974993000,
+ "url":"images\/thumbs\/zack_sink.jpg"
+ }
+ ]
+}
+var store = new Ext.data.JsonStore({
+ url: 'get-images.php',
+ root: 'images',
+ fields: [
+ 'name', 'url',
+ {name:'size', type: 'float'},
+ {name:'lastmod', type:'date', dateFormat:'timestamp'}
+ ]
+});
+store.load();
+
+var listView = new Ext.list.ListView({
+ store: store,
+ multiSelect: true,
+ emptyText: 'No images to display',
+ reserveScrollOffset: true,
+ columns: [{
+ header: 'File',
+ width: .5,
+ dataIndex: 'name'
+ },{
+ header: 'Last Modified',
+ width: .35,
+ dataIndex: 'lastmod',
+ tpl: '{lastmod:date("m-d h:i a")}'
+ },{
+ header: 'Size',
+ dataIndex: 'size',
+ tpl: '{size:fileSize}', // format using Ext.util.Format.fileSize()
+ align: 'right'
+ }]
+});
+
+// put it in a Panel so it looks pretty
+var panel = new Ext.Panel({
+ id:'images-view',
+ width:425,
+ height:250,
+ collapsible:true,
+ layout:'fit',
+ title:'Simple ListView <i>(0 items selected)</i>',
+ items: listView
+});
+panel.render(document.body);
+
+// little bit of feedback
+listView.on('selectionchange', function(view, nodes){
+ var l = nodes.length;
+ var s = l != 1 ? 's' : '';
+ panel.setTitle('Simple ListView <i>('+l+' item'+s+' selected)</i>');
+});
+ * </code></pre>
+ * @constructor
+ * @param {Object} config
+ * @xtype listview
+ */
+Ext.list.ListView = Ext.extend(Ext.DataView, {
+ /**
+ * Set this property to <tt>true</tt> to disable the header click handler disabling sort
+ * (defaults to <tt>false</tt>).
+ * @type Boolean
+ * @property disableHeaders
+ */
+ /**
+ * @cfg {Boolean} hideHeaders
+ * <tt>true</tt> to hide the {@link #internalTpl header row} (defaults to <tt>false</tt> so
+ * the {@link #internalTpl header row} will be shown).
+ */
+ /**
+ * @cfg {String} itemSelector
+ * Defaults to <tt>'dl'</tt> to work with the preconfigured <b><tt>{@link Ext.DataView#tpl tpl}</tt></b>.
+ * This setting specifies the CSS selector (e.g. <tt>div.some-class</tt> or <tt>span:first-child</tt>)
+ * that will be used to determine what nodes the ListView will be working with.
+ */
+ itemSelector: 'dl',
+ /**
+ * @cfg {String} selectedClass The CSS class applied to a selected row (defaults to
+ * <tt>'x-list-selected'</tt>). An example overriding the default styling:
+ <pre><code>
+ .x-list-selected {background-color: yellow;}
+ </code></pre>
+ * @type String
+ */
+ selectedClass:'x-list-selected',
+ /**
+ * @cfg {String} overClass The CSS class applied when over a row (defaults to
+ * <tt>'x-list-over'</tt>). An example overriding the default styling:
+ <pre><code>
+ .x-list-over {background-color: orange;}
+ </code></pre>
+ * @type String
+ */
+ overClass:'x-list-over',
+ /**
+ * @cfg {Boolean} reserveScrollOffset
+ * By default will defer accounting for the configured <b><tt>{@link #scrollOffset}</tt></b>
+ * for 10 milliseconds. Specify <tt>true</tt> to account for the configured
+ * <b><tt>{@link #scrollOffset}</tt></b> immediately.
+ */
+ /**
+ * @cfg {Number} scrollOffset The amount of space to reserve for the scrollbar (defaults to
+ * <tt>undefined</tt>). If an explicit value isn't specified, this will be automatically
+ * calculated.
+ */
+ scrollOffset : undefined,
+ /**
+ * @cfg {Boolean/Object} columnResize
+ * Specify <tt>true</tt> or specify a configuration object for {@link Ext.list.ListView.ColumnResizer}
+ * to enable the columns to be resizable (defaults to <tt>true</tt>).
+ */
+ columnResize: true,
+ /**
+ * @cfg {Array} columns An array of column configuration objects, for example:
+ * <pre><code>
+{
+ align: 'right',
+ dataIndex: 'size',
+ header: 'Size',
+ tpl: '{size:fileSize}',
+ width: .35
+}
+ * </code></pre>
+ * Acceptable properties for each column configuration object are:
+ * <div class="mdetail-params"><ul>
+ * <li><b><tt>align</tt></b> : String<div class="sub-desc">Set the CSS text-align property
+ * of the column. Defaults to <tt>'left'</tt>.</div></li>
+ * <li><b><tt>dataIndex</tt></b> : String<div class="sub-desc">See {@link Ext.grid.Column}.
+ * {@link Ext.grid.Column#dataIndex dataIndex} for details.</div></li>
+ * <li><b><tt>header</tt></b> : String<div class="sub-desc">See {@link Ext.grid.Column}.
+ * {@link Ext.grid.Column#header header} for details.</div></li>
+ * <li><b><tt>tpl</tt></b> : String<div class="sub-desc">Specify a string to pass as the
+ * configuration string for {@link Ext.XTemplate}. By default an {@link Ext.XTemplate}
+ * will be implicitly created using the <tt>dataIndex</tt>.</div></li>
+ * <li><b><tt>width</tt></b> : Number<div class="sub-desc">Percentage of the container width
+ * this column should be allocated. Columns that have no width specified will be
+ * allocated with an equal percentage to fill 100% of the container width. To easily take
+ * advantage of the full container width, leave the width of at least one column undefined.
+ * Note that if you do not want to take up the full width of the container, the width of
+ * every column needs to be explicitly defined.</div></li>
+ * </ul></div>
+ */
+ /**
+ * @cfg {Boolean/Object} columnSort
+ * Specify <tt>true</tt> or specify a configuration object for {@link Ext.list.ListView.Sorter}
+ * to enable the columns to be sortable (defaults to <tt>true</tt>).
+ */
+ columnSort: true,
+ /**
+ * @cfg {String/Array} internalTpl
+ * The template to be used for the header row. See {@link #tpl} for more details.
+ */
+
+ /*
+ * IE has issues when setting percentage based widths to 100%. Default to 99.
+ */
+ maxWidth: Ext.isIE ? 99 : 100,
+
+ initComponent : function(){
+ if(this.columnResize){
+ this.colResizer = new Ext.list.ColumnResizer(this.colResizer);
+ this.colResizer.init(this);
+ }
+ if(this.columnSort){
+ this.colSorter = new Ext.list.Sorter(this.columnSort);
+ this.colSorter.init(this);
+ }
+ if(!this.internalTpl){
+ this.internalTpl = new Ext.XTemplate(
+ '<div class="x-list-header"><div class="x-list-header-inner">',
+ '<tpl for="columns">',
+ '<div style="width:{[values.width*100]}%;text-align:{align};"><em unselectable="on" id="',this.id, '-xlhd-{#}">',
+ '{header}',
+ '</em></div>',
+ '</tpl>',
+ '<div class="x-clear"></div>',
+ '</div></div>',
+ '<div class="x-list-body"><div class="x-list-body-inner">',
+ '</div></div>'
+ );
+ }
+ if(!this.tpl){
+ this.tpl = new Ext.XTemplate(
+ '<tpl for="rows">',
+ '<dl>',
+ '<tpl for="parent.columns">',
+ '<dt style="width:{[values.width*100]}%;text-align:{align};">',
+ '<em unselectable="on"<tpl if="cls"> class="{cls}</tpl>">',
+ '{[values.tpl.apply(parent)]}',
+ '</em></dt>',
+ '</tpl>',
+ '<div class="x-clear"></div>',
+ '</dl>',
+ '</tpl>'
+ );
+ };
+
+ var cs = this.columns,
+ allocatedWidth = 0,
+ colsWithWidth = 0,
+ len = cs.length,
+ columns = [];
+
+ for(var i = 0; i < len; i++){
+ var c = cs[i];
+ if(!c.isColumn) {
+ c.xtype = c.xtype ? (/^lv/.test(c.xtype) ? c.xtype : 'lv' + c.xtype) : 'lvcolumn';
+ c = Ext.create(c);
+ }
+ if(c.width) {
+ allocatedWidth += c.width*100;
+ colsWithWidth++;
+ }
+ columns.push(c);
+ }
+
+ cs = this.columns = columns;
+
+ // auto calculate missing column widths
+ if(colsWithWidth < len){
+ var remaining = len - colsWithWidth;
+ if(allocatedWidth < this.maxWidth){
+ var perCol = ((this.maxWidth-allocatedWidth) / remaining)/100;
+ for(var j = 0; j < len; j++){
+ var c = cs[j];
+ if(!c.width){
+ c.width = perCol;
+ }
+ }
+ }
+ }
+ Ext.list.ListView.superclass.initComponent.call(this);
+ },
+
+ onRender : function(){
+ this.autoEl = {
+ cls: 'x-list-wrap'
+ };
+ Ext.list.ListView.superclass.onRender.apply(this, arguments);
+
+ this.internalTpl.overwrite(this.el, {columns: this.columns});
+
+ this.innerBody = Ext.get(this.el.dom.childNodes[1].firstChild);
+ this.innerHd = Ext.get(this.el.dom.firstChild.firstChild);
+
+ if(this.hideHeaders){
+ this.el.dom.firstChild.style.display = 'none';
+ }
+ },
+
+ getTemplateTarget : function(){
+ return this.innerBody;
+ },
+
+ /**
+ * <p>Function which can be overridden which returns the data object passed to this
+ * view's {@link #tpl template} to render the whole ListView. The returned object
+ * shall contain the following properties:</p>
+ * <div class="mdetail-params"><ul>
+ * <li><b>columns</b> : String<div class="sub-desc">See <tt>{@link #columns}</tt></div></li>
+ * <li><b>rows</b> : String<div class="sub-desc">See
+ * <tt>{@link Ext.DataView}.{@link Ext.DataView#collectData collectData}</div></li>
+ * </ul></div>
+ * @param {Array} records An Array of {@link Ext.data.Record}s to be rendered into the DataView.
+ * @param {Number} startIndex the index number of the Record being prepared for rendering.
+ * @return {Object} A data object containing properties to be processed by a repeating
+ * XTemplate as described above.
+ */
+ collectData : function(){
+ var rs = Ext.list.ListView.superclass.collectData.apply(this, arguments);
+ return {
+ columns: this.columns,
+ rows: rs
+ }
+ },
+
+ verifyInternalSize : function(){
+ if(this.lastSize){
+ this.onResize(this.lastSize.width, this.lastSize.height);
+ }
+ },
+
+ // private
+ onResize : function(w, h){
+ var bd = this.innerBody.dom;
+ var hd = this.innerHd.dom;
+ if(!bd){
+ return;
+ }
+ var bdp = bd.parentNode;
+ if(Ext.isNumber(w)){
+ var sw = w - Ext.num(this.scrollOffset, Ext.getScrollBarWidth());
+ if(this.reserveScrollOffset || ((bdp.offsetWidth - bdp.clientWidth) > 10)){
+ bd.style.width = sw + 'px';
+ hd.style.width = sw + 'px';
+ }else{
+ bd.style.width = w + 'px';
+ hd.style.width = w + 'px';
+ setTimeout(function(){
+ if((bdp.offsetWidth - bdp.clientWidth) > 10){
+ bd.style.width = sw + 'px';
+ hd.style.width = sw + 'px';
+ }
+ }, 10);
+ }
+ }
+ if(Ext.isNumber(h)){
+ bdp.style.height = (h - hd.parentNode.offsetHeight) + 'px';
+ }
+ },
+
+ updateIndexes : function(){
+ Ext.list.ListView.superclass.updateIndexes.apply(this, arguments);
+ this.verifyInternalSize();
+ },
+
+ findHeaderIndex : function(hd){
+ hd = hd.dom || hd;
+ var pn = hd.parentNode, cs = pn.parentNode.childNodes;
+ for(var i = 0, c; c = cs[i]; i++){
+ if(c == pn){
+ return i;
+ }
+ }
+ return -1;
+ },
+
+ setHdWidths : function(){
+ var els = this.innerHd.dom.getElementsByTagName('div');
+ for(var i = 0, cs = this.columns, len = cs.length; i < len; i++){
+ els[i].style.width = (cs[i].width*100) + '%';
+ }
+ }
+});
+
+Ext.reg('listview', Ext.list.ListView);
+
+// Backwards compatibility alias
+Ext.ListView = Ext.list.ListView;/**
+ * @class Ext.list.Column
+ * <p>This class encapsulates column configuration data to be used in the initialization of a
+ * {@link Ext.list.ListView ListView}.</p>
+ * <p>While subclasses are provided to render data in different ways, this class renders a passed
+ * data field unchanged and is usually used for textual columns.</p>
+ */
+Ext.list.Column = Ext.extend(Object, {
+ /**
+ * @private
+ * @cfg {Boolean} isColumn
+ * Used by ListView constructor method to avoid reprocessing a Column
+ * if <code>isColumn</code> is not set ListView will recreate a new Ext.list.Column
+ * Defaults to true.
+ */
+ isColumn: true,
+
+ /**
+ * @cfg {String} align
+ * Set the CSS text-align property of the column. Defaults to <tt>'left'</tt>.
+ */
+ align: 'left',
+ /**
+ * @cfg {String} header Optional. The header text to be used as innerHTML
+ * (html tags are accepted) to display in the ListView. <b>Note</b>: to
+ * have a clickable header with no text displayed use <tt>' '</tt>.
+ */
+ header: '',
+
+ /**
+ * @cfg {Number} width Optional. Percentage of the container width
+ * this column should be allocated. Columns that have no width specified will be
+ * allocated with an equal percentage to fill 100% of the container width. To easily take
+ * advantage of the full container width, leave the width of at least one column undefined.
+ * Note that if you do not want to take up the full width of the container, the width of
+ * every column needs to be explicitly defined.
+ */
+ width: null,
+
+ /**
+ * @cfg {String} cls Optional. This option can be used to add a CSS class to the cell of each
+ * row for this column.
+ */
+ cls: '',
+
+ /**
+ * @cfg {String} tpl Optional. Specify a string to pass as the
+ * configuration string for {@link Ext.XTemplate}. By default an {@link Ext.XTemplate}
+ * will be implicitly created using the <tt>dataIndex</tt>.
+ */
+
+ /**
+ * @cfg {String} dataIndex <p><b>Required</b>. The name of the field in the
+ * ListViews's {@link Ext.data.Store}'s {@link Ext.data.Record} definition from
+ * which to draw the column's value.</p>
+ */
+
+ constructor : function(c){
+ if(!c.tpl){
+ c.tpl = new Ext.XTemplate('{' + c.dataIndex + '}');
+ }
+ else if(Ext.isString(c.tpl)){
+ c.tpl = new Ext.XTemplate(c.tpl);
+ }
+
+ Ext.apply(this, c);
+ }
+});
+
+Ext.reg('lvcolumn', Ext.list.Column);
+
+/**
+ * @class Ext.list.NumberColumn
+ * @extends Ext.list.Column
+ * <p>A Column definition class which renders a numeric data field according to a {@link #format} string. See the
+ * {@link Ext.list.Column#xtype xtype} config option of {@link Ext.list.Column} for more details.</p>
+ */
+Ext.list.NumberColumn = Ext.extend(Ext.list.Column, {
+ /**
+ * @cfg {String} format
+ * A formatting string as used by {@link Ext.util.Format#number} to format a numeric value for this Column
+ * (defaults to <tt>'0,000.00'</tt>).
+ */
+ format: '0,000.00',
+
+ constructor : function(c) {
+ c.tpl = c.tpl || new Ext.XTemplate('{' + c.dataIndex + ':number("' + (c.format || this.format) + '")}');
+ Ext.list.NumberColumn.superclass.constructor.call(this, c);
+ }
+});
+
+Ext.reg('lvnumbercolumn', Ext.list.NumberColumn);
+
+/**
+ * @class Ext.list.DateColumn
+ * @extends Ext.list.Column
+ * <p>A Column definition class which renders a passed date according to the default locale, or a configured
+ * {@link #format}. See the {@link Ext.list.Column#xtype xtype} config option of {@link Ext.list.Column}
+ * for more details.</p>
+ */
+Ext.list.DateColumn = Ext.extend(Ext.list.Column, {
+ format: 'm/d/Y',
+ constructor : function(c) {
+ c.tpl = c.tpl || new Ext.XTemplate('{' + c.dataIndex + ':date("' + (c.format || this.format) + '")}');
+ Ext.list.DateColumn.superclass.constructor.call(this, c);
+ }
+});
+Ext.reg('lvdatecolumn', Ext.list.DateColumn);
+
+/**
+ * @class Ext.list.BooleanColumn
+ * @extends Ext.list.Column
+ * <p>A Column definition class which renders boolean data fields. See the {@link Ext.list.Column#xtype xtype}
+ * config option of {@link Ext.list.Column} for more details.</p>
+ */
+Ext.list.BooleanColumn = Ext.extend(Ext.list.Column, {
+ /**
+ * @cfg {String} trueText
+ * The string returned by the renderer when the column value is not falsey (defaults to <tt>'true'</tt>).
+ */
+ trueText: 'true',
+ /**
+ * @cfg {String} falseText
+ * The string returned by the renderer when the column value is falsey (but not undefined) (defaults to
+ * <tt>'false'</tt>).
+ */
+ falseText: 'false',
+ /**
+ * @cfg {String} undefinedText
+ * The string returned by the renderer when the column value is undefined (defaults to <tt>' '</tt>).
+ */
+ undefinedText: ' ',
+
+ constructor : function(c) {
+ c.tpl = c.tpl || new Ext.XTemplate('{' + c.dataIndex + ':this.format}');
+
+ var t = this.trueText, f = this.falseText, u = this.undefinedText;
+ c.tpl.format = function(v){
+ if(v === undefined){
+ return u;
+ }
+ if(!v || v === 'false'){
+ return f;
+ }
+ return t;
+ };
+
+ Ext.list.DateColumn.superclass.constructor.call(this, c);
+ }
+});
+
+Ext.reg('lvbooleancolumn', Ext.list.BooleanColumn);/**
+ * @class Ext.list.ColumnResizer
+ * @extends Ext.util.Observable
+ * <p>Supporting Class for Ext.list.ListView</p>
+ * @constructor
+ * @param {Object} config
+ */
+Ext.list.ColumnResizer = Ext.extend(Ext.util.Observable, {
+ /**
+ * @cfg {Number} minPct The minimum percentage to allot for any column (defaults to <tt>.05</tt>)
+ */
+ minPct: .05,
+
+ constructor: function(config){
+ Ext.apply(this, config);
+ Ext.list.ColumnResizer.superclass.constructor.call(this);
+ },
+ init : function(listView){
+ this.view = listView;
+ listView.on('render', this.initEvents, this);
+ },
+
+ initEvents : function(view){
+ view.mon(view.innerHd, 'mousemove', this.handleHdMove, this);
+ this.tracker = new Ext.dd.DragTracker({
+ onBeforeStart: this.onBeforeStart.createDelegate(this),
+ onStart: this.onStart.createDelegate(this),
+ onDrag: this.onDrag.createDelegate(this),
+ onEnd: this.onEnd.createDelegate(this),
+ tolerance: 3,
+ autoStart: 300
+ });
+ this.tracker.initEl(view.innerHd);
+ view.on('beforedestroy', this.tracker.destroy, this.tracker);
+ },
+
+ handleHdMove : function(e, t){
+ var hw = 5,
+ x = e.getPageX(),
+ hd = e.getTarget('em', 3, true);
+ if(hd){
+ var r = hd.getRegion(),
+ ss = hd.dom.style,
+ pn = hd.dom.parentNode;
+
+ if(x - r.left <= hw && pn != pn.parentNode.firstChild){
+ this.activeHd = Ext.get(pn.previousSibling.firstChild);
+ ss.cursor = Ext.isWebKit ? 'e-resize' : 'col-resize';
+ } else if(r.right - x <= hw && pn != pn.parentNode.lastChild.previousSibling){
+ this.activeHd = hd;
+ ss.cursor = Ext.isWebKit ? 'w-resize' : 'col-resize';
+ } else{
+ delete this.activeHd;
+ ss.cursor = '';
+ }
+ }
+ },
+
+ onBeforeStart : function(e){
+ this.dragHd = this.activeHd;
+ return !!this.dragHd;
+ },
+
+ onStart: function(e){
+ this.view.disableHeaders = true;
+ this.proxy = this.view.el.createChild({cls:'x-list-resizer'});
+ this.proxy.setHeight(this.view.el.getHeight());
+
+ var x = this.tracker.getXY()[0],
+ w = this.view.innerHd.getWidth();
+
+ this.hdX = this.dragHd.getX();
+ this.hdIndex = this.view.findHeaderIndex(this.dragHd);
+
+ this.proxy.setX(this.hdX);
+ this.proxy.setWidth(x-this.hdX);
+
+ this.minWidth = w*this.minPct;
+ this.maxWidth = w - (this.minWidth*(this.view.columns.length-1-this.hdIndex));
+ },
+
+ onDrag: function(e){
+ var cursorX = this.tracker.getXY()[0];
+ this.proxy.setWidth((cursorX-this.hdX).constrain(this.minWidth, this.maxWidth));
+ },
+
+ onEnd: function(e){
+ /* calculate desired width by measuring proxy and then remove it */
+ var nw = this.proxy.getWidth();
+ this.proxy.remove();
+
+ var index = this.hdIndex,
+ vw = this.view,
+ cs = vw.columns,
+ len = cs.length,
+ w = this.view.innerHd.getWidth(),
+ minPct = this.minPct * 100,
+ pct = Math.ceil((nw * vw.maxWidth) / w),
+ diff = (cs[index].width * 100) - pct,
+ eachItem = Math.floor(diff / (len-1-index)),
+ mod = diff - (eachItem * (len-1-index));
+
+ for(var i = index+1; i < len; i++){
+ var cw = (cs[i].width * 100) + eachItem,
+ ncw = Math.max(minPct, cw);
+ if(cw != ncw){
+ mod += cw - ncw;
+ }
+ cs[i].width = ncw / 100;
+ }
+ cs[index].width = pct / 100;
+ cs[index+1].width += (mod / 100);
+ delete this.dragHd;
+ vw.setHdWidths();
+ vw.refresh();
+ setTimeout(function(){
+ vw.disableHeaders = false;
+ }, 100);
+ }
+});
+
+// Backwards compatibility alias
+Ext.ListView.ColumnResizer = Ext.list.ColumnResizer;/**
+ * @class Ext.list.Sorter
+ * @extends Ext.util.Observable
+ * <p>Supporting Class for Ext.list.ListView</p>
+ * @constructor
+ * @param {Object} config
+ */
+Ext.list.Sorter = Ext.extend(Ext.util.Observable, {
+ /**
+ * @cfg {Array} sortClasses
+ * The CSS classes applied to a header when it is sorted. (defaults to <tt>["sort-asc", "sort-desc"]</tt>)
+ */
+ sortClasses : ["sort-asc", "sort-desc"],
+
+ constructor: function(config){
+ Ext.apply(this, config);
+ Ext.list.Sorter.superclass.constructor.call(this);
+ },
+
+ init : function(listView){
+ this.view = listView;
+ listView.on('render', this.initEvents, this);
+ },
+
+ initEvents : function(view){
+ view.mon(view.innerHd, 'click', this.onHdClick, this);
+ view.innerHd.setStyle('cursor', 'pointer');
+ view.mon(view.store, 'datachanged', this.updateSortState, this);
+ this.updateSortState.defer(10, this, [view.store]);
+ },
+
+ updateSortState : function(store){
+ var state = store.getSortState();
+ if(!state){
+ return;
+ }
+ this.sortState = state;
+ var cs = this.view.columns, sortColumn = -1;
+ for(var i = 0, len = cs.length; i < len; i++){
+ if(cs[i].dataIndex == state.field){
+ sortColumn = i;
+ break;
+ }
+ }
+ if(sortColumn != -1){
+ var sortDir = state.direction;
+ this.updateSortIcon(sortColumn, sortDir);
+ }
+ },
+
+ updateSortIcon : function(col, dir){
+ var sc = this.sortClasses;
+ var hds = this.view.innerHd.select('em').removeClass(sc);
+ hds.item(col).addClass(sc[dir == "DESC" ? 1 : 0]);
+ },
+
+ onHdClick : function(e){
+ var hd = e.getTarget('em', 3);
+ if(hd && !this.view.disableHeaders){
+ var index = this.view.findHeaderIndex(hd);
+ this.view.store.sort(this.view.columns[index].dataIndex);
+ }
+ }
+});
+
+// Backwards compatibility alias
+Ext.ListView.Sorter = Ext.list.Sorter;
\ No newline at end of file