1. #1
    Sencha User
    Join Date
    Apr 2012
    Posts
    16
    Answers
    1
    Vote Rating
    0
    csanchezr85 is on a distinguished road

      0  

    Default 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.

  2. 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.

  3. #2
    Ext JS Premium Member tvanzoelen's Avatar
    Join Date
    Apr 2008
    Location
    Groningen - Netherlands
    Posts
    1,111
    Answers
    83
    Vote Rating
    30
    tvanzoelen has a spectacular aura about tvanzoelen has a spectacular aura about tvanzoelen has a spectacular aura about

      0  

    Default


    Code:
    e.stopEvent()
    ?

  4. #3
    Sencha User
    Join Date
    Apr 2012
    Posts
    16
    Answers
    1
    Vote Rating
    0
    csanchezr85 is on a distinguished road

      0  

    Default


    Thanks for your reply. I think that I must use something like this, tvanzoelen, but in the code:

    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);
                        }
                    });
    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.

  5. #4
    Ext JS Premium Member tvanzoelen's Avatar
    Join Date
    Apr 2008
    Location
    Groningen - Netherlands
    Posts
    1,111
    Answers
    83
    Vote Rating
    30
    tvanzoelen has a spectacular aura about tvanzoelen has a spectacular aura about tvanzoelen has a spectacular aura about

      0  

    Default


    You can set your sorter function on the Store

    Code:
    var store = Ext.create('Ext.data.Store', {
         model: 'User',
         sorters: [{
             property: 'age',
             direction: 'DESC'
         }, {
             property: 'firstName',
             direction: 'ASC'
         }],
    
         filters: [{
             property: 'firstName',
             value: /Ed/
         }]
     });
    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.

    seel also: http://docs.sencha.com/ext-js/4-1/#!...xt.util.Sorter

  6. #5
    Sencha User
    Join Date
    Apr 2012
    Posts
    16
    Answers
    1
    Vote Rating
    0
    csanchezr85 is on a distinguished road

      0  

    Default


    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.

Thread Participants: 1

Tags for this Thread