Results 1 to 3 of 3

Thread: beforedestroy on formpanel

  1. #1
    Sencha User
    Join Date
    Jul 2009
    Posts
    61

    Default beforedestroy on formpanel

    Hi, I have a tree on the left and for each node of that tree, a formpanel is rendering on the right.

    I'm trying to check if that form has been changed and to warn for saving the changes if any when I'm clicking on another tree node (or anywhere else on the interface that would replace my rendered form).

    For that, I tought I would use the beforedestroy event of this formpanel, trigger a confirmation window, and cancel the orignal click action if the user choose cancel.

    Here is the code ( right now, I bypassed the user confirmation and am trying to cancel the destroy event anyway ) :

    PHP Code:
    //DETAILS PANEL    
        
    function CreateDetailsPanel(MyFormStructure,node_id){
        
    //console.log(node_id);
        
    var pan3 = new Ext.Panel({
            
    id:'DetailsPanel',
            
    xtype    'form',        
            
    labelWidth:200,
            
    padding:'5 5 5 5',    
            
    frame:false,                
            
    autoScroll    true,
            
    title    'Details',    
            
    iconCls        'search_page',                    
            
    items: [{                        
                
    xtype'tabpanel',
                
    width:650,
                
    height:550,
                
    activeTab0,                        
                
    items: [{
                        
    title'Main',         
                        
    padding'10 10 10 10',            
                        
    labelWidth200,
                        
    layout'form',    
                        
    autoScroll:true,                    
                        
    itemsMyFormStructure
                            
    //,buttons: [{    text: 'Login'},{text:'Cancel'}]        
                
    }]
            }],    
            
    tbar:[
                {
                    
    text:'Highlight this node',
                    
    iconCls:'back'
                    
    qtip:'Highlight this node in the Budget Tree',
                    
    listeners:{
                        
    click:function(){
                            var 
    MyNode MyTree.getNodeById(node_id);
                            var 
    MyPathMyNode.getPath();
                            
    MyTree.selectPath(MyPath);
                        }
                    }
                }
            ],        
            
    listeners: {
                
    beforedestroy: function(panel){    
                    
    console.log(panel);            
                    
    Ext.Msg.show({
                        
    title:'Save your work?',
                        
    iconExt.MessageBox.QUESTION,
                        
    msg:'You did some changes on this form. Are you sure you want to leave without saving?',
                        
    minWidth:300,
                        
    buttonsExt.Msg.YESNO
                    
    });

                    return 
    false;
                }
            }
        });
        return 
    pan3;
        }; 
    The thing is: I understand that even if my code is maybe attempting to cancel the destroy, somewhere else, due to my click, it is still trying to override it with something else. What I don't understand is where and how I'm supposed to cancel the click event itself?

    Thank you very mutch for your enlightened tips :-)
    all:true

  2. #2
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364

    Default

    Look at the API. The click event will pass the event object, which is what you'll do to cancel the click event.

  3. #3
    Sencha User
    Join Date
    Jul 2009
    Posts
    61

    Default

    Hello J. I must confess I did not understood your answer. But anyway I decided o handle the warning in a different way, precisely with adding click events to the two possible actions that would have destroyed the form.

    And sorry for the delay reading you. When i asked, the formum was down for a time.

    Regards.
    all:true

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •