Last active
December 25, 2015 13:19
-
-
Save bmancini55/6982569 to your computer and use it in GitHub Desktop.
An ExtJS 4.2 feature extension for the summary feature. This new code adds click events for the summary.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ext.define('Mancini.extension.grid.feature.ClickableSummary', { | |
extend: 'Ext.grid.feature.Summary', | |
alias: ['feature.clickablesummary'], | |
mixins: { | |
observable: 'Ext.util.Observable' | |
}, | |
relayedEvents: [ | |
'summaryclick' | |
], | |
constructor: function(config) { | |
var me = this; | |
me.addEvents( | |
'summaryclick' | |
); | |
me.callParent(arguments); | |
me.mixins.observable.constructor.call(me); | |
}, | |
init: function(grid) { | |
var me = this; | |
// wire click event to dom cell click | |
grid.on({ | |
afterrender: function () { | |
this.mon(this.el, 'click', me.onSummaryCellClick, me, { delegate: '.x-grid-cell' }); | |
} | |
}); | |
grid.relayEvents(me, me.relayedEvents); | |
me.callParent(arguments); | |
}, | |
onSummaryCellClick: function (e, target) { | |
var me = this, | |
cell = Ext.get(target), | |
row = cell.up(me.summaryRowSelector); | |
// only execute if this was inside summary row | |
// as mentioned in init, there may be a cleaner way to implement this | |
if (row) { | |
var grid = Ext.getCmp(cell.up('.x-grid').id), | |
column = grid.columns[cell.dom.cellIndex], | |
record = me.summaryRecord, | |
cellIndex = cell.dom.cellIndex, | |
rowIndex = -1; | |
me.fireEvent('summaryclick', me, cell, cellIndex, record, row, rowIndex, e); | |
} | |
}, | |
renderTFoot: function(values, out) { | |
var view = values.view, | |
me = view.findFeature('clickablesummary'); | |
if (me.showSummaryRow) { | |
out.push('<tfoot>'); | |
me.outputSummaryRecord(me.createSummaryRecord(view), values, out); | |
out.push('</tfoot>'); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment