1. #1
    Sencha User
    Join Date
    Jul 2012
    Posts
    6
    Vote Rating
    0
    kramarskiy is on a distinguished road

      0  

    Default How to combine confirm MessageBox with beforeselect event on treegrid?

    How to combine confirm MessageBox with beforeselect event on treegrid?


    I'm facing a problem that i need to ask user for an action when he switches from node to node on treegrid, i'm using beforeselect event within controller and Ext.MessageBox.confirm, so after user pushes the button on messagebox i need to be able select the node he wanted to select or cancel the selection. My problem is that confirm message passes the node to be selected, i can't return false because beforeselect event function works behind the messagebox. Does anyone know how to make it working ?

  2. #2
    Sencha - Community Support Team sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,333
    Vote Rating
    85
    sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough

      0  

    Default


    Hi!

    may you provide your code so i may take further action for your problem
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  3. #3
    Sencha User
    Join Date
    Jul 2012
    Posts
    6
    Vote Rating
    0
    kramarskiy is on a distinguished road

      0  

    Default


    yes, sure

    Code:
    this.control({
                'treepanel[id="my-tree"]': {
                    beforeselect: function(view, record,  index,  options) { 
                            var check = this.makeCheck();
                            var out = false; //or true - depends on question in alert
                            if(check){
                                Ext.MessageBox.confirm('Confirm', 'Are you sure you want to do that?',                      function(btn){
    
                                    out = true;  //or false - depends on question in alert
                                    
                                }, this);
                            }
                            return out;
    }
                    }

  4. #4
    Sencha - Community Support Team sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,333
    Vote Rating
    85
    sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough

      0  

    Default


    HI!

    try this:-

    Code:
     beforeselect: function(view, record,  index,  options) { 
        var check = this.makeCheck(); 
        if(check){
              Ext.MessageBox.confirm(
                       'Confirm'
                       , 'Are you sure you want to do that?'
                       , function (btn) {
                           if (btn == 'yes') {
                               // do what ever you want here...
                           }
                       }
                   );
        }
    }
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  5. #5
    Sencha User
    Join Date
    Jul 2012
    Posts
    6
    Vote Rating
    0
    kramarskiy is on a distinguished road

      0  

    Default


    suppose after pressing yes button i want to cancel selection, how can i do that? if i return false after i check yes button it doesn't work, treegrid revices nothing(that means that row can be selected) before user takes an action and press Yes button

  6. #6
    Sencha - Community Support Team sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,333
    Vote Rating
    85
    sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough

      0  

    Default


    Quote Originally Posted by kramarskiy View Post
    suppose after pressing yes button i want to cancel selection, how can i do that? if i return false after i check yes button it doesn't work, treegrid revices nothing(that means that row can be selected) before user takes an action and press Yes button
    why you need to cancel if it is already confirm by user in confirm box?
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  7. #7
    Sencha User
    Join Date
    Jul 2012
    Posts
    6
    Vote Rating
    0
    kramarskiy is on a distinguished road

      0  

    Default


    ok, what if user presses No button?

  8. #8
    Sencha User
    Join Date
    Jul 2012
    Posts
    6
    Vote Rating
    0
    kramarskiy is on a distinguished road

      0  

    Default


    yes, but it doesn't work that way ... that is question!

  9. #9
    Sencha - Community Support Team sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,333
    Vote Rating
    85
    sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough

      0  

    Default


    Quote Originally Posted by kramarskiy View Post
    ok, what if user presses No button?

    you may return false if user clicks on NO button
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  10. #10
    Sencha - Community Support Team sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,333
    Vote Rating
    85
    sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough

      0  

    Default


    it should work, have you checked API Docs?

    beforeselect( Ext.selection.RowModel this, Ext.data.Model record, Number index, Object eOpts )
    Fired before a record is selected. If any listener returns false, the selection is cancelled.

    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

Thread Participants: 1