Results 1 to 4 of 4

Thread: How to disable the Drag Drop of nodes within TreePanel...................

  1. #1
    Sencha User poojagarg89's Avatar
    Join Date
    Sep 2011
    Location
    Ahmedabad,India
    Posts
    213

    Default How to disable the Drag Drop of nodes within TreePanel...................

    How to disable the Drag Drop of nodes within TreePanel...................

    My requirement is :
    I have a TreePanel and a GridPanel....................I wanna drag records from GridPanel to TreeNodes so I have given ddGroup in GridPanel and TreePanel as same "GridDD" and my logic is working fine

    I have used "beforenodedrop" event for making my functionality work for drag drop of grid data to TreePanel's node.

    but I can drag TreeNodes in TreePanel and can drop in TreePanel itself and that particular dragged treenode becomes sub child of the node where it is dropped.........................but I WANT TO DISABLE DragDrop within TreePanel so I cannot drag treenodes within TreePanel.

  2. #2
    Sencha User poojagarg89's Avatar
    Join Date
    Sep 2011
    Location
    Ahmedabad,India
    Posts
    213

    Default Code

    here is the code:
    Code:
    run_management_root=new Ext.tree.TreeNode({
        text:'Manage Runs',
        id:'root_id',
        expanded:true,
        iconCls:'parent_folder'
        });
    run_management_root.appendChild(
        new Ext.tree.TreeNode({
                 text:'Customers with NO runs',
                 scope:this,
                 iconCls:'red_b'
        })
    );
    
    Ext.app.runManagementLoader = Ext.extend(Ext.ux.XmlTreeLoader, {
        processAttributes : function(attr){
        
      
        if(attr.loc_name){ 
                 attr.text   = attr.loc_name;
                 attr.id = attr.loc_id;
                 attr.loaded = true;
                }  
        else if(attr.run_name){ 
        
           var run=(attr.run_id).split(":");
         var status;
         if(run[2]=="green")
          {
            status="green_b";
          }else{
            status="red_b";
          }
                 attr.text = attr.run_name;
                 attr.id = attr.run_id;
                 attr.iconCls=status;
                 attr.loaded = true;
                }
        
        }
    });            
    loading_runmanagement_loader =new Ext.app.runManagementLoader({
                    id:"runmanagement_loader_id",
                     dataUrl:projname+'/ShowRunsTree',
                     baseParams:{load_type:"run_management"}
     });
    run_management_reloadroot = run_management_root.appendChild(
    new Ext.tree.AsyncTreeNode({
        text:'Run Control',
        id:'run_management_runcontrol_id',
        expanded:true,
        loader:loading_runmanagement_loader
        })
    );
    
    run_management_panel = new Ext.tree.TreePanel({
        id: 'run_management_panel',
        border:false,
        collapsible: false,
        autoScroll: true,
        rootVisible: true,
        enableDD:true,
        ddGroup : 'GridDD',
        height: 460,
        lines: true,
        layout:"fit",
        root:run_management_root,
        listeners:{
            beforenodedrop:{
               fn:function(e) {
                    if(Ext.isArray(e.data.selections)) {
                        var inv_code;
                        var sel_node=Ext.getCmp("run_management_panel").getSelectionModel().getSelectedNode();
                        
                               e.cancel = false;
                               e.dropNode = [];
                               var t = e.target; 
                               var str1=t.attributes.id;
                               var str=t.attributes.text;
                               str=str.split(":");
                               str1=str1.split(":");
                             if(t.attributes.text=="Run Control") //  if(t.parentNode.attributes.text!="Packages")
                               {
                                 Ext.Msg.show({
                                     title:"Error",
                                     msg:"You can not move to the Run sets.",
                                     icon:Ext.Msg.ERROR,
                                      buttons:Ext.Msg.OK,
                                      modal:true
                                   });
                                   return false;
                               }else if(t.parentNode.attributes.text=="Run Control") //  if(t.parentNode.attributes.text!="Packages")
                               {
                                 Ext.Msg.show({
                                     title:"Error",
                                     msg:"You can not move to the Run sets.",
                                     icon:Ext.Msg.ERROR,
                                      buttons:Ext.Msg.OK,
                                      modal:true
                                   });
                                   return false;
                               }
                               var r;
                                for(var i = 0; i < e.data.selections.length; i++) {
                                r = e.data.selections[i];
                                 if(str1[0].trim()==r.get('run_id').trim())
                                  {
                                        Ext.Msg.show({
                                     title:"Error",
                                     msg:"You are moving to the same run.",
                                     icon:Ext.Msg.ERROR,
                                      buttons:Ext.Msg.OK,
                                      modal:true
                                   });
                                   return false;
                                  }
                                  var customer_id = r.get('customer_id');
                                  var old_run_id = r.get('run_id');
                                  var run_line_id = r.get('run_line_id');
                                  var sm1 = Ext.getCmp("run_management_panel").getSelectionModel();
                                  var rec1 = sm1.getSelectedNode();
                                  if(rec1.text=="Customers with NO runs"){
                                      Ext.Ajax.request({
                                        url: projname+"/mediator", success: function(response){
                                            if(response.responseText == "failure"){
                                                Ext.Msg.alert("Error"," Delivery Point is not assigned to the selected customer");
                                            }else{
                                            Ext.Msg.alert("Success","Customer moved to specific run successfully");
                                                run_management_ds.load({
                                                       params:{load_type:"customersnotonrun"}
                                                   });
                                                   run_management_reloadroot.reload();
                                            }
                                        },params:{operation:"CustomerMoveToRun",nextpage:"web/jsp/wh_homepage.jsp",customer_id:customer_id,new_sequence_no:"0",run_id:str1[0]}
                                    });
                                  }else{
                                    Ext.Ajax.request({
                                        url:projname+"/mediator",success: function(response){
                                            
                                             run_management_ds.load({
                                              params:{load_type:"runs",run_id:old_run_id}
                                              });
                                              run_management_reloadroot.reload(function(records,option,success){
                                                 var nod=run_management_reloadroot.findChild("text",t.parentNode.attributes.text);
                                                 var nod1=nod.findChild("text",sel_node.text);
                                                alert(nod1.text);
                                                 Ext.getCmp("run_management_panel").focus(nod1.text);
                                              });
                                        },
                                        params:{operation:"UpdateRunSequence_OtherRun",nextpage:"web/jsp/wh_homepage.jsp",customer_id:customer_id,sequence_no:'0',old_run_id:old_run_id,new_run_id:str1[0],run_line_id:run_line_id}
                                    });
                                 }
                              }
                    }
                    return true;
               }
            }
    }
    });


    It comes out to be like this:


  3. #3
    Sencha User
    Join Date
    Jan 2011
    Posts
    549

    Default

    Add "enableDrop: true" to your treePanel. This allows items to be dropped onto it, but not dragged from it:
    http://docs.sencha.com/ext-js/3-4/#!...cfg-enableDrop

  4. #4
    Sencha User poojagarg89's Avatar
    Join Date
    Sep 2011
    Location
    Ahmedabad,India
    Posts
    213

    Default

    Thanks willigogs
    I caught my mistake ................actually I was applying this enableDrop: true but
    enableDD: true was also there in TreePanel n thats y it was not working

    Thanks again

Posting Permissions

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