-
30 Aug 2012 4:46 AM #1
Answered: How to avoid that an event executes its action
Answered: How to avoid that an event executes its action
Hello,
basically, I want to "tell" to the event that it doesn't have to execute its action. I explain my example: I have a grid (ext.grid.Panel) and I've added the listener for the "sortchange" event. When user clicks on a column to sort it, obviously this event is fired.
But the problem is that I only want the column and direction parameters in order to call to an own function to sort the grid by these parameters and others. And the event first sorts by its criterion and after my function sorts again, creating an ugly effect. So I want that the event doesn't raise its order action.
How can I do this?
Thanks.
-
Best Answer Posted by csanchezr85
I've proved this. I have added a sorter function but it's still reordering the grid. I only want the column and direction sort, and defining a sorter function in the store I only get access to the direction, but I don´t know how to obtain the column.
But finally I've opted to make columns not sorteables and I've added the 'headerclick' to them. So when user clicks on a header I add the css class to it (to indicate the direction of the sort) and call to my function that sorts the records.
Thanks for your responses.
-
30 Aug 2012 4:47 AM #2Ext JS Premium Member
- Join Date
- Apr 2008
- Location
- Groningen - Netherlands
- Posts
- 1,017
- Vote Rating
- 23
- Answers
- 75
?Code:e.stopEvent()
-
30 Aug 2012 10:39 PM #3
Thanks for your reply. I think that I must use something like this, tvanzoelen, but in the code:
in the 'sortchange' event I don't have the event ('e') parameter and if I include the instruction 'e.stopEvent();', the event gives me an error.Code://Control the sorter columns g.on('sortchange', function (container, column, dir, opts) { if (_self.pagingBar != null) { _self.pagingBar.sortColumn = column.dataIndex; _self.pagingBar.sortDir = dir; //Load data _self.pagingBar.getData(_self.pagingBar); } });
-
31 Aug 2012 12:03 AM #4Ext JS Premium Member
- Join Date
- Apr 2008
- Location
- Groningen - Netherlands
- Posts
- 1,017
- Vote Rating
- 23
- Answers
- 75
You can set your sorter function on the Store
In the case above the sorter is an object , but you couild also set your function there, then then will be the default sorter for the grid.Code:var store = Ext.create('Ext.data.Store', { model: 'User', sorters: [{ property: 'age', direction: 'DESC' }, { property: 'firstName', direction: 'ASC' }], filters: [{ property: 'firstName', value: /Ed/ }] });
seel also: http://docs.sencha.com/ext-js/4-1/#!...xt.util.Sorter
-
31 Aug 2012 2:28 AM #5
I've proved this. I have added a sorter function but it's still reordering the grid. I only want the column and direction sort, and defining a sorter function in the store I only get access to the direction, but I don´t know how to obtain the column.
But finally I've opted to make columns not sorteables and I've added the 'headerclick' to them. So when user clicks on a header I add the css class to it (to indicate the direction of the sort) and call to my function that sorts the records.
Thanks for your responses.


Reply With Quote