-
7 Nov 2011 7:11 AM #1
How to exclude certain rows from sorting?
How to exclude certain rows from sorting?
Hi all.
I am new to ExtJS and i have written an web-application which features a GridPanel (grouped and ungrouped) and I want to prevent sorting certain rows (which represent summary rows).
I have already tried
http://www.sencha.com/forum/showthre...-grid-s-footer
but it didn't work for me.
I am using ExtJS 3.4.
Can somebody give some hints. Thank you very much in advance.
-
7 Nov 2011 11:38 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,582
- Vote Rating
- 434
If you don't want a column to be sortable by clicking on the header, specify the 'sortable' config to false on the column.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
7 Nov 2011 1:43 PM #3
Hi mitchellsimoens,
thanks for your reply.
I dont't want to prevent sorting on a column. I want to exclude certain rows from sorting.
I tried to remove the rows when the sortchange event is fired and insert them afterwards at the same position in the grid. But this only works for ungrouped grids.
An alternative approach would be to create a custom sorting function. All the examples I found didn't fit my needs.
I tried the following code (http://www.sencha.com/forum/showthre...-grid-s-footer), but I always get the error "this.fields.get(f) is undefined".
Is there a detailed example of how to create a custom sorting function?PHP Code:Ext.data.MyGroupingStore = Ext.extend(Ext.data.GroupingStore, {
// private
sortData : function(f, direction){
direction = direction || 'ASC';
var st = this.fields.get(f).sortType;
var fn = function(r1, r2){
var row_type1 = r1.data['row_type'];
var row_type2 = r2.data['row_type'];
if ((row_type1 == 'sum') && (direction == 'ASC'))
return 1;
if ((row_type2 == 'sum') && (direction == 'ASC'))
return -1;
if ((row_type1 == 'sum') && (direction == 'DESC'))
return -1;
if ((row_type2 == 'sum') && (direction == 'DESC'))
return 1;
var v1 = st(r1.data[f]), v2 = st(r2.data[f]);
return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
};
this.data.sort(direction, fn);
if(this.snapshot && this.snapshot != this.data){
this.snapshot.sort(direction, fn);
}
}
});
Thanks in advance!
-
8 Nov 2011 7:57 AM #4
-
8 Nov 2011 12:44 PM #5
Hi scarsick,
the rows that i want to leave on the same position are representing summary rows in the GridPanel.
After examing the source code I was able to solve the problem.
Cheers,
Seha


Reply With Quote