⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 columnmodel.js

📁 Ext JS是一个创建丰富互联网应用程序的跨浏览器的JavaScrip库。它包含:高效率
💻 JS
📖 第 1 页 / 共 2 页
字号:
  return c.hidden;});</code></pre>     * @param {Function} fn     * @param {Object} scope (optional)     * @return {Array} result     */    getColumnsBy : function(fn, scope){        var r = [];        for(var i = 0, len = this.config.length; i < len; i++){            var c = this.config[i];            if(fn.call(scope||this, c, i) === true){                r[r.length] = c;            }        }        return r;    },    /**     * Returns true if the specified column is sortable.     * @param {Number} col The column index     * @return {Boolean}     */    isSortable : function(col){        return this.config[col].sortable;    },    /**     * Returns true if the specified column menu is disabled.     * @param {Number} col The column index     * @return {Boolean}     */    isMenuDisabled : function(col){        return !!this.config[col].menuDisabled;    },    /**     * Returns the rendering (formatting) function defined for the column.     * @param {Number} col The column index.     * @return {Function} The function used to render the cell. See {@link #setRenderer}.     */    getRenderer : function(col){        if(!this.config[col].renderer){            return Ext.grid.ColumnModel.defaultRenderer;        }        return this.config[col].renderer;    },    /**     * Sets the rendering (formatting) function for a column.  See {@link Ext.util.Format} for some     * default formatting functions.     * @param {Number} col The column index     * @param {Function} fn The function to use to process the cell's raw data     * to return HTML markup for the grid view. The render function is called with     * the following parameters:<ul>     * <li><b>value</b> : Object<p class="sub-desc">The data value for the cell.</p></li>     * <li><b>metadata</b> : Object<p class="sub-desc">An object in which you may set the following attributes:<ul>     * <li><b>css</b> : String<p class="sub-desc">A CSS class name to add to the cell's TD element.</p></li>     * <li><b>attr</b> : String<p class="sub-desc">An HTML attribute definition string to apply to the data container element <i>within</i> the table cell     * (e.g. 'style="color:red;"').</p></li></ul></p></li>     * <li><b>record</b> : Ext.data.record<p class="sub-desc">The {@link Ext.data.Record} from which the data was extracted.</p></li>     * <li><b>rowIndex</b> : Number<p class="sub-desc">Row index</p></li>     * <li><b>colIndex</b> : Number<p class="sub-desc">Column index</p></li>     * <li><b>store</b> : Ext.data.Store<p class="sub-desc">The {@link Ext.data.Store} object from which the Record was extracted.</p></li></ul>     */    setRenderer : function(col, fn){        this.config[col].renderer = fn;    },    /**     * Returns the width for the specified column.     * @param {Number} col The column index     * @return {Number}     */    getColumnWidth : function(col){        return this.config[col].width;    },    /**     * Sets the width for a column.     * @param {Number} col The column index     * @param {Number} width The new width     */    setColumnWidth : function(col, width, suppressEvent){        this.config[col].width = width;        this.totalWidth = null;        if(!suppressEvent){             this.fireEvent("widthchange", this, col, width);        }    },    /**     * Returns the total width of all columns.     * @param {Boolean} includeHidden True to include hidden column widths     * @return {Number}     */    getTotalWidth : function(includeHidden){        if(!this.totalWidth){            this.totalWidth = 0;            for(var i = 0, len = this.config.length; i < len; i++){                if(includeHidden || !this.isHidden(i)){                    this.totalWidth += this.getColumnWidth(i);                }            }        }        return this.totalWidth;    },    /**     * Returns the header for the specified column.     * @param {Number} col The column index     * @return {String}     */    getColumnHeader : function(col){        return this.config[col].header;    },    /**     * Sets the header for a column.     * @param {Number} col The column index     * @param {String} header The new header     */    setColumnHeader : function(col, header){        this.config[col].header = header;        this.fireEvent("headerchange", this, col, header);    },    /**     * Returns the tooltip for the specified column.     * @param {Number} col The column index     * @return {String}     */    getColumnTooltip : function(col){            return this.config[col].tooltip;    },    /**     * Sets the tooltip for a column.     * @param {Number} col The column index     * @param {String} tooltip The new tooltip     */    setColumnTooltip : function(col, tooltip){            this.config[col].tooltip = tooltip;    },    /**     * Returns the dataIndex for the specified column.<pre><code>// Get field name for the columnvar fieldName = grid.getColumnModel().getDataIndex(columnIndex);</code></pre>     * @param {Number} col The column index     * @return {String} The column's dataIndex     */    getDataIndex : function(col){        return this.config[col].dataIndex;    },    /**     * Sets the dataIndex for a column.     * @param {Number} col The column index     * @param {String} dataIndex The new dataIndex     */    setDataIndex : function(col, dataIndex){        this.config[col].dataIndex = dataIndex;    },    /**     * Finds the index of the first matching column for the given dataIndex.     * @param {String} col The dataIndex to find     * @return {Number} The column index, or -1 if no match was found     */    findColumnIndex : function(dataIndex){        var c = this.config;        for(var i = 0, len = c.length; i < len; i++){            if(c[i].dataIndex == dataIndex){                return i;            }        }        return -1;    },    /**     * Returns true if the cell is editable.<pre><code>var store = new Ext.data.Store({...});var colModel = new Ext.grid.ColumnModel({  columns: [...],  isCellEditable: function(col, row) {    var record = store.getAt(row);    if (record.get('readonly')) { // replace with your condition      return false;    }    return Ext.grid.ColumnModel.prototype.isCellEditable.call(this, col, row);  }});var grid = new Ext.grid.GridPanel({  store: store,  colModel: colModel,  ...});</code></pre>     * @param {Number} colIndex The column index     * @param {Number} rowIndex The row index     * @return {Boolean}     */    isCellEditable : function(colIndex, rowIndex){        return (this.config[colIndex].editable || (typeof this.config[colIndex].editable == "undefined" && this.config[colIndex].editor)) ? true : false;    },    /**     * Returns the editor defined for the cell/column.     * @param {Number} colIndex The column index     * @param {Number} rowIndex The row index     * @return {Ext.Editor} The {@link Ext.Editor Editor} that was created to wrap     * the {@link Ext.form.Field Field} used to edit the cell.     */    getCellEditor : function(colIndex, rowIndex){        return this.config[colIndex].getCellEditor(rowIndex);    },    /**     * Sets if a column is editable.     * @param {Number} col The column index     * @param {Boolean} editable True if the column is editable     */    setEditable : function(col, editable){        this.config[col].editable = editable;    },    /**     * Returns true if the column is hidden.     * @param {Number} colIndex The column index     * @return {Boolean}     */    isHidden : function(colIndex){        return this.config[colIndex].hidden;    },    /**     * Returns true if the column width cannot be changed     */    isFixed : function(colIndex){        return this.config[colIndex].fixed;    },    /**     * Returns true if the column can be resized     * @return {Boolean}     */    isResizable : function(colIndex){        return colIndex >= 0 && this.config[colIndex].resizable !== false && this.config[colIndex].fixed !== true;    },    /**     * Sets if a column is hidden.<pre><code>myGrid.getColumnModel().setHidden(0, true); // hide column 0 (0 = the first column).  </code></pre>     * @param {Number} colIndex The column index     * @param {Boolean} hidden True if the column is hidden     */    setHidden : function(colIndex, hidden){        var c = this.config[colIndex];        if(c.hidden !== hidden){            c.hidden = hidden;            this.totalWidth = null;            this.fireEvent("hiddenchange", this, colIndex, hidden);        }    },    /**     * Sets the editor for a column and destroys the prior editor.     * @param {Number} col The column index     * @param {Object} editor The editor object     */    setEditor : function(col, editor){        Ext.destroy(this.config[col].editor);        this.config[col].editor = editor;    },        /**     * Destroys this the column model by purging any event listeners, and removing any editors.     */    destroy : function(){        var c = this.config;        for(var i = 0, c = this.config, len = c.length; i < len; i++){            Ext.destroy(c[i].editor);        }        this.purgeListeners();    }});// privateExt.grid.ColumnModel.defaultRenderer = function(value){    if(typeof value == "string" && value.length < 1){        return "&#160;";    }    return value;};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -