X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/0494b8d9b9bb03ab6c22b34dae81261e3cd7e3e6..7a654f8d43fdb43d78b63d90528bed6e86b608cc:/src/grid/property/HeaderContainer.js?ds=sidebyside diff --git a/src/grid/property/HeaderContainer.js b/src/grid/property/HeaderContainer.js new file mode 100644 index 00000000..aa7fd4df --- /dev/null +++ b/src/grid/property/HeaderContainer.js @@ -0,0 +1,92 @@ +/** + * @class Ext.grid.property.HeaderContainer + * @extends Ext.grid.header.Container + * A custom HeaderContainer for the {@link Ext.grid.property.Grid}. Generally it should not need to be used directly. + * @constructor + * @param {Ext.grid.property.Grid} grid The grid this store will be bound to + * @param {Object} source The source data config object + */ +Ext.define('Ext.grid.property.HeaderContainer', { + + extend: 'Ext.grid.header.Container', + + alternateClassName: 'Ext.grid.PropertyColumnModel', + + // private - strings used for locale support + nameText : 'Name', + valueText : 'Value', + dateFormat : 'm/j/Y', + trueText: 'true', + falseText: 'false', + + // private + nameColumnCls: Ext.baseCSSPrefix + 'grid-property-name', + + constructor : function(grid, store) { + + this.grid = grid; + this.store = store; + this.callParent([{ + items: [{ + header: this.nameText, + width: 115, + sortable: true, + dataIndex: grid.nameField, + renderer: Ext.Function.bind(this.renderProp, this), + itemId: grid.nameField, + menuDisabled :true, + tdCls: this.nameColumnCls + }, { + header: this.valueText, + renderer: Ext.Function.bind(this.renderCell, this), + getEditor: function(record) { + return grid.getCellEditor(record, this); + }, + flex: 1, + fixed: true, + dataIndex: grid.valueField, + itemId: grid.valueField, + menuDisabled: true + }] + }]); + }, + + // private + // Render a property name cell + renderProp : function(v) { + return this.getPropertyName(v); + }, + + // private + // Render a property value cell + renderCell : function(val, meta, rec) { + var me = this, + renderer = this.grid.customRenderers[rec.get(me.grid.nameField)], + result = val; + + if (renderer) { + return renderer.apply(this, arguments); + } + if (Ext.isDate(val)) { + result = this.renderDate(val); + } else if (Ext.isBoolean(val)) { + result = this.renderBool(val); + } + return Ext.util.Format.htmlEncode(result); + }, + + // private + renderDate : Ext.util.Format.date, + + // private + renderBool : function(bVal) { + return this[bVal ? 'trueText' : 'falseText']; + }, + + // private + // Renders custom property names instead of raw names if defined in the Grid + getPropertyName : function(name) { + var pn = this.grid.propertyNames; + return pn && pn[name] ? pn[name] : name; + } +}); \ No newline at end of file