PDA

View Full Version : Its.grid.feature.Sorting



vietits
16 Jan 2012, 7:07 PM
Hi all,

I've developed Its.grid.feature.Sorting that allows to multi-sort from grid interface. Here are some features:

Toggle between single sort and multi-sort mode (default).
Allow setting the order of sorting (in case of multi-sort mode) by the order of columns (default) or by order of adding sort.
In multi-sort mode, the sort will be updated in the following cases:

Change the order of columns by dragging
Add or remove a column from sort

Add a column to sort by clicking its title or select items from grid column menu.
Remove a column from sort by clicking its title (in case column.sortStates >= 3) or selecting an item on the grid column menu.
Remove all columns from sort by selecting an item on the grid column menu.
Hope that this is useful to you. Any feedback will be welcome!

Screenshot of grid column menu
30758

Source code
30759

mitchellsimoens
16 Jan 2012, 9:11 PM
Very nice!

ajaxvador
17 Jan 2012, 12:49 AM
+1 =D>

zacware
20 Jan 2012, 6:12 AM
Great! Thanks! Just what I was looking for!

dawesi
18 Dec 2012, 1:29 PM
nice one

canxss
8 Jan 2013, 2:43 AM
Hi,

It seems a very nice feature. Something that I've been looking for but unfortunately I couldn't make it work on ext-4.2.0-beta. Probably because of the changes in this new version.

First I couldn't get the feature to be inited at all then I examined the code like all other grid features it didn't have an init function to initialize and attach events. I've added an init function calling the attachEvents function inside it and it finally started to appear functioning :)

Then I realized it started to clear my initial sorters and I've changed the "else if (dir == null)" as else "if (dir === null)" in doSort function.

And at the end I found that when the Container's setSortState is called, it sets the sortState just for the first column as shown below:


setSortState: function(){
var store = this.up('[store]').store,
// grab the first sorter, since there may also be groupers
// in this collection
first = store.getFirstSorter(),
hd;


if (first) {
hd = this.down('gridcolumn[dataIndex=' + first.property +']');
if (hd) {
hd.setSortState(first.direction, false, true);
}
} else {
this.clearOtherSortStates(null);
}
},




So at the end I couldn't make a multiple sort configuration on my store to appear with the feature.

I hope you find the time to revise this necessary feature to overcome these problems.

Thanks in advance

Ipek