-
24 Jul 2012 3:00 PM #1
call sort on grid column after grid initially loaded
call sort on grid column after grid initially loaded
Hi,
Have searched the forums for this but could not find anything.
I was to sort my grid after its loaded.
In the store.load callback function
store.load({
scope: this,
callback: function(records, operation, success) {
console.log(success);
-->>>> some call here to call the ascending sort function for a give grid column
}
});
After the grid has been loaded, I want to pragmatically call the ascending sort function for a give column.
Any ideas or pointers is greatly appreciated, thanks in advance
-
24 Jul 2012 3:40 PM #2
Sort the store and the grid will dynamically update itself.
Aaron Conran
@aconran
Sencha Architect Development Team
-
24 Jul 2012 3:59 PM #3
call sort on grid column after grid initially loaded:
call sort on grid column after grid initially loaded:
Thanks, for the fast reply, I did that, see below, it does indeed sort based on the Severity column when its initially loaded, however, it does not seem to honor the doSort I have overidden in my view and seems to sort on the default alphabetic sort. If I click on the severity column button after its been loaded, it sorts as expected. based on the doSort I have overidden.
So everything appear to be working fine, except the doSort I have overriden in the view does not seem to be used on the "initial" load of the grid.
the doSort is show below also,
Code:constructor: function(cfg) { var me = this; cfg = cfg || {}; me.callParent([Ext.apply({ autoLoad: false, autoSync: true, filterOnLoad: false, storeId: 'MyJsonStore', model: 'MyApp.model.Alerts', purgePageCount: false, sorters: { property: 'Severity' } }, cfg)]); } doSort : function(state) { var field = this.getSortParam(); var ds = this.up('gridpanel').store; console.log('doSort field: ' + field ); ds.sort({ property : field, direction : state, sorterFn : function(v1, v2) { v1 = v1.get(field); v2 = v2.get(field); var sevA = me.getSeverityNumber(v1); var sevB = me.getSeverityNumber(v2); var eq = (sevA == sevB ? 0 : (sevA > sevB ? 1 : -1)); return eq; } }); },Last edited by aconran; 24 Jul 2012 at 4:08 PM. Reason: add code tags
-
24 Jul 2012 4:15 PM #4
The proper way to do this is at the data level with a custom sortType:
http://docs.sencha.com/ext-js/4-1/#!...data.SortTypes
Unfortunately we currently have a bug regarding using custom sortTypes within Sencha Architect.
This will be added in the near future:
http://www.sencha.com/forum/showthread.php?229975Aaron Conran
@aconran
Sencha Architect Development Team
-
24 Jul 2012 4:30 PM #5
call sort on grid column after grid initially loaded:
call sort on grid column after grid initially loaded:
Thanks, will be waiting for the bug fix.


Reply With Quote