TreeNode - Ext.msg.confirm

  1. #1

    TreeNode - Ext.msg.confirm

    Hi All,

    I have below two functions, when ever user click on the treenode it wil select the selected value. When the user tries to switch to another node i should pop up a message with yes/No button. If the user clicks on yes it should remain on same treenode or else move to the new node. How do i get that ?

    init: function () {
            this.loadStores();
            this.control({
                '#btnApiBuilderExport': { click: this.onBtnApiBuilderExport },
                'assettreepanel': { itemclick: this.onTreeNodeSelected },        
                '#searchAssetTree': { change: { fn: this.searchAssetTree, buffer: 300} }
    
            });
        },
     
    
    onTreeNodeSelected: function (view, record, item, index) {
            nodeSelectedvalue = record;
            var attributeFilterCtrl = this.application.getController('AttributeFilterCtrl');
    
            var selAttributeStore = Ext.getStore('apibuilder.SelectedAttributes');
            var selFilterStore = Ext.getStore('apibuilder.Filters');
    
            if (selAttributeStore.data.length > 0 || selFilterStore.data.length > 0) {
                Ext.Msg.confirm('Save Changes?', 'You are changing Asset type that may have unused changes. Would you like to save your changes?', function (btn, text) {
                    if (btn == 'yes') {
                   }
               }, this);
           }
            attributeFilterCtrl.refreshStores();
        }
    Thank
    sree
    Last edited by fabricio.murta; Jan 09, 2016 at 12:18 AM.
  2. #2
    Hello @sreekanth! And welcome to Ext.NET Forums!

    Can you confirm this is for Ext.NET 3.2.1, or is it for any other version, like 2.x? I should move this question to the correct forum.

    As for your question, just bind a listener to BeforeSelect event of your treePanel!

    For example,
    <BeforeSelect Fn="handleSelectionChange" />
    And to start with, a function that prevents the actual selection change:
        <script type="text/javascript">
            var handleSelectionChange = function (item, record) {
                var curSelection = item.getSelection();
                if (curSelection.length > 0) {
                    var curItem = curSelection[0].data.text,
                        newItem = record.data.text;
                    console.log('Selection will change from "' + curItem + '" to "' + newItem + '".');
                    return false;
                }
            }
        </script>
    so you can display your confirmation message and then call a method/callback (if clicked 'yes') to effectively change the selection. You'd probably need to set a bit somewhere so, when the selection change happens, the hander function above shouldn't return 'false'.

    I hope this helps!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. [CLOSED] Ext.Msg.Confirm vs Confirm with DirectEvents
    By csharpdev in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jan 21, 2013, 10:51 AM
  2. Replies: 2
    Last Post: Jul 10, 2012, 8:09 PM
  3. X.Msg.Confirm Value does not define
    By tgosoriano in forum 1.x Help
    Replies: 5
    Last Post: May 16, 2012, 12:57 PM
  4. password confirm
    By maxdiable in forum 1.x Help
    Replies: 3
    Last Post: Aug 19, 2010, 3:07 PM
  5. Replies: 0
    Last Post: Dec 10, 2009, 11:14 AM

Posting Permissions