Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / docs / source / ListView.html
diff --git a/docs/source/ListView.html b/docs/source/ListView.html
deleted file mode 100644 (file)
index 449be7a..0000000
+++ /dev/null
@@ -1,381 +0,0 @@
-<html>\r
-<head>\r
-  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    \r
-  <title>The source code</title>\r
-    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
-    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
-</head>\r
-<body  onload="prettyPrint();">\r
-    <pre class="prettyprint lang-js"><div id="cls-Ext.list.ListView"></div>/**\r
- * @class Ext.list.ListView\r
- * @extends Ext.DataView\r
- * <p>Ext.list.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.list.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.list.ListView = Ext.extend(Ext.DataView, {\r
-    <div id="prop-Ext.list.ListView-disableHeaders"></div>/**\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
-    <div id="cfg-Ext.list.ListView-hideHeaders"></div>/**\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
-    <div id="cfg-Ext.list.ListView-itemSelector"></div>/**\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
-    <div id="cfg-Ext.list.ListView-selectedClass"></div>/**\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
-    <div id="cfg-Ext.list.ListView-overClass"></div>/**\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
-    <div id="cfg-Ext.list.ListView-reserveScrollOffset"></div>/**\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
-    <div id="cfg-Ext.list.ListView-scrollOffset"></div>/**\r
-     * @cfg {Number} scrollOffset The amount of space to reserve for the scrollbar (defaults to\r
-     * <tt>undefined</tt>). If an explicit value isn't specified, this will be automatically\r
-     * calculated.\r
-     */\r
-    scrollOffset : undefined,\r
-    <div id="cfg-Ext.list.ListView-columnResize"></div>/**\r
-     * @cfg {Boolean/Object} columnResize\r
-     * Specify <tt>true</tt> or specify a configuration object for {@link Ext.list.ListView.ColumnResizer}\r
-     * to enable the columns to be resizable (defaults to <tt>true</tt>).\r
-     */\r
-    columnResize: true,\r
-    <div id="cfg-Ext.list.ListView-columns"></div>/**\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
-    <div id="cfg-Ext.list.ListView-columnSort"></div>/**\r
-     * @cfg {Boolean/Object} columnSort\r
-     * Specify <tt>true</tt> or specify a configuration object for {@link Ext.list.ListView.Sorter}\r
-     * to enable the columns to be sortable (defaults to <tt>true</tt>).\r
-     */\r
-    columnSort: true,\r
-    <div id="cfg-Ext.list.ListView-internalTpl"></div>/**\r
-     * @cfg {String/Array} internalTpl\r
-     * The template to be used for the header row.  See {@link #tpl} for more details.\r
-     */\r
-\r
-    /*\r
-     * IE has issues when setting percentage based widths to 100%. Default to 99.\r
-     */\r
-    maxWidth: Ext.isIE ? 99 : 100,\r
-    \r
-    initComponent : function(){\r
-        if(this.columnResize){\r
-            this.colResizer = new Ext.list.ColumnResizer(this.colResizer);\r
-            this.colResizer.init(this);\r
-        }\r
-        if(this.columnSort){\r
-            this.colSorter = new Ext.list.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:{[values.width*100]}%;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:{[values.width*100]}%;text-align:{align};">',\r
-                        '<em unselectable="on"<tpl if="cls"> class="{cls}</tpl>">',\r
-                            '{[values.tpl.apply(parent)]}',\r
-                        '</em></dt>',\r
-                        '</tpl>',\r
-                        '<div class="x-clear"></div>',\r
-                    '</dl>',\r
-                '</tpl>'\r
-            );\r
-        };\r
-        \r
-        var cs = this.columns, \r
-            allocatedWidth = 0, \r
-            colsWithWidth = 0, \r
-            len = cs.length, \r
-            columns = [];\r
-            \r
-        for(var i = 0; i < len; i++){\r
-            var c = cs[i];\r
-            if(!c.isColumn) {\r
-                c.xtype = c.xtype ? (/^lv/.test(c.xtype) ? c.xtype : 'lv' + c.xtype) : 'lvcolumn';\r
-                c = Ext.create(c);\r
-            }\r
-            if(c.width) {\r
-                allocatedWidth += c.width*100;\r
-                colsWithWidth++;\r
-            }\r
-            columns.push(c);\r
-        }\r
-        \r
-        cs = this.columns = columns;\r
-        \r
-        // auto calculate missing column widths\r
-        if(colsWithWidth < len){\r
-            var remaining = len - colsWithWidth;\r
-            if(allocatedWidth < this.maxWidth){\r
-                var perCol = ((this.maxWidth-allocatedWidth) / remaining)/100;\r
-                for(var j = 0; j < len; j++){\r
-                    var c = cs[j];\r
-                    if(!c.width){\r
-                        c.width = perCol;\r
-                    }\r
-                }\r
-            }\r
-        }\r
-        Ext.list.ListView.superclass.initComponent.call(this);\r
-    },\r
-\r
-    onRender : function(){\r
-        this.autoEl = {\r
-            cls: 'x-list-wrap'  \r
-        };\r
-        Ext.list.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
-    <div id="method-Ext.list.ListView-collectData"></div>/**\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.list.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 - Ext.num(this.scrollOffset, Ext.getScrollBarWidth());\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)){\r
-            bdp.style.height = (h - hd.parentNode.offsetHeight) + 'px';\r
-        }\r
-    },\r
-\r
-    updateIndexes : function(){\r
-        Ext.list.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*100) + '%';\r
-        }\r
-    }\r
-});\r
-\r
-Ext.reg('listview', Ext.list.ListView);\r
-\r
-// Backwards compatibility alias\r
-Ext.ListView = Ext.list.ListView;</pre>    \r
-</body>\r
-</html>
\ No newline at end of file