2 * @class Ext.ux.PreviewPlugin
3 * @extends Ext.AbstractPlugin
5 * The Preview enables you to show a configurable preview of a record.
7 * This plugin assumes that it has control over the features used for this
8 * particular grid section and may conflict with other plugins.
10 * @alias plugin.preview
13 Ext.define('Ext.ux.PreviewPlugin', {
14 extend: 'Ext.AbstractPlugin',
15 alias: 'plugin.preview',
16 requires: ['Ext.grid.feature.RowBody', 'Ext.grid.feature.RowWrap'],
18 // private, css class to use to hide the body
19 hideBodyCls: 'x-grid-row-body-hidden',
22 * @cfg {String} bodyField
23 * Field to display in the preview. Must me a field within the Model definition
24 * that the store is using.
29 * @cfg {Boolean} previewExpanded
31 previewExpanded: true,
33 constructor: function(config) {
34 this.callParent(arguments);
35 var bodyField = this.bodyField,
36 hideBodyCls = this.hideBodyCls,
37 section = this.getCmp();
39 section.previewExpanded = this.previewExpanded;
42 getAdditionalData: function(data, idx, record, orig, view) {
43 var o = Ext.grid.feature.RowBody.prototype.getAdditionalData.apply(this, arguments);
45 rowBody: data[bodyField],
46 rowBodyCls: section.previewExpanded ? '' : hideBodyCls
56 * Toggle between the preview being expanded/hidden
57 * @param {Boolean} expanded Pass true to expand the record and false to not show the preview.
59 toggleExpanded: function(expanded) {
60 var view = this.getCmp();
61 this.previewExpanded = view.previewExpanded = expanded;