1. #1
    Ext User
    Join Date
    Nov 2007
    Posts
    18
    Vote Rating
    0
    debtman7 is on a distinguished road

      0  

    Default tree events not firing

    tree events not firing


    Hi,

    I'm trying to get a tree going with server updates to save the sorting and I'm having problems with the events. The code is:

    Code:
    var url = root + 'manage/feed/tree';
    
    Ext.onReady( function() {
    	var tree = new Ext.tree.TreePanel({
    		el: 'treeDiv',
    		autoScroll: true,
    		animate: true,
    		enableDD: true,
    		containerScroll: true,
    		loader: new Ext.tree.TreeLoader({
    			dataUrl: url
    		})
    	});
    	
    	var root = new Ext.tree.AsyncTreeNode({
    		text: 'Order Website',
    		draggable: false,
    		id: 'root'
    	});
    	
    	tree.on('beforemove', function(o) { alert('hi'); });
    	
    		
    	tree.setRootNode(root);
    	tree.render();
    	
    	root.expand();
    });
    The json data returned from the server is a multi-dimensional array and I'm wondering if that's the problem. The data is:

    Code:
    [{"id":"individuals","text":"Individuals","cls":"folder","children":[{"text":"Home","id":"39","cls":"file","leaf":"true"},{"text":"Learn About Medicare Part D","id":"44","cls":"file","leaf":"true"},{"text":"Look Up Prescription Drugs","id":"46","cls":"file","leaf":"true"},{"text":"Member Resources","id":"69","children":[{"text":"Comprehensive Formularies","id":"17","cls":"file","leaf":"true"},{"text":"Evidence of coverage","id":"24","cls":"file","leaf":"true"},{"text":"Exceptions and appeals","id":"25","cls":"file","leaf":"true"},{"text":"Frequently asked questions","id":"28","cls":"file","leaf":"true"},{"text":"Glossary","id":"30","cls":"file","leaf":"true"},{"text":"Grievances","id":"32","cls":"file","leaf":"true"},{"text":"Notices and announcements","id":"56","cls":"file","leaf":"true"},{"text":"Summary of Benefits","id":"71","cls":"file","leaf":"true"}],"cls":"folder"},{"text":"Contact Your Plan Sponsor","id":"18","cls":"file","leaf":"true"},{"text":"Find a Network Pharmacy","id":"26","cls":"file","leaf":"true"},{"text":"Learn about out plans","id":"1","cls":"file","leaf":"true"},{"text":"Your Rights And Protection","id":"92","cls":"file","leaf":"true"},{"text":"Information For Caregivers And Family","id":"40","children":[{"text":"Additional help for low-income seniors","id":"5","cls":"file","leaf":"true"},{"text":"Becoming a Designated Representative","id":"9","cls":"file","leaf":"true"},{"text":"Checklist for Plan Enrollment","id":"15","cls":"file","leaf":"true"}],"cls":"folder"},{"text":"Group Login","id":"34","cls":"file","leaf":"true"},{"text":"Manage Your Plan","id":"47","children":[{"text":"Appoint A Representative","id":"7","cls":"file","leaf":"true"},{"text":"Get Coverage For Your Prescription Drugs","id":"29","cls":"file","leaf":"true"},{"text":"Out of Network Coverage","id":"58","cls":"file","leaf":"true"},{"text":"Reduce your prescription drug costs","id":"68","cls":"file","leaf":"true"},{"text":"Transition Policy","id":"73","cls":"file","leaf":"true"},{"text":"Restrictions to Our Covered Drugs","id":"75","cls":"file","leaf":"true"}],"cls":"folder"},{"text":"Test 2","id":"97","children":[{"text":"all_about_formularies","id":"6","cls":"file","leaf":"true"},{"text":"Disenrolling from a plan","id":"74","cls":"file","leaf":"true"},{"text":"privacy_policy","id":"65","cls":"file","leaf":"true"},{"text":"states_options","id":"70","cls":"file","leaf":"true"},{"text":"changes_2007","id":"14","cls":"file","leaf":"true"},{"text":"pharmacy_locator","id":"62","cls":"file","leaf":"true"},{"text":"choice_plan_2007","id":"16","cls":"file","leaf":"true"},{"text":"delta_disclaimer","id":"19","cls":"file","leaf":"true"},{"text":"Learn about our plans","id":"93","cls":"file","leaf":"true"},{"text":"learn_about_our_plans","id":"94","cls":"file","leaf":"true"},{"text":"learn_about_our_plans","id":"95","cls":"file","leaf":"true"}],"cls":"folder"},{"text":"forms_and_notices","id":"27","cls":"file","leaf":"true"}]},{"id":"groups","text":"Employers & Groups","cls":"folder","children":[{"text":"home","id":"33","children":[{"text":"group_login_sample","id":"36","cls":"file","leaf":"true"},{"text":"group_login_group","id":"35","cls":"file","leaf":"true"},{"text":"about_memberhealth","id":"2","cls":"file","leaf":"true"}],"cls":"folder"}]},{"id":"pharmacists","text":"Pharmacists","cls":"folder","children":[{"text":"pharmacists","id":"59","children":[{"text":"pharmacist_parent_page","id":"61","cls":"file","leaf":"true"},{"text":"member_enrollment_form_for_pharmacists","id":"49","cls":"file","leaf":"true"},{"text":"pharmacists_dummy_page","id":"60","cls":"file","leaf":"true"}],"cls":"folder"}]},{"id":"producers","text":"Producers","cls":"folder","children":[{"text":"home","id":"66","cls":"file","leaf":"true"}]},{"id":"mhrx","text":"MemberHealth","cls":"folder","children":[{"text":"mhrx","id":"50","children":[{"text":"about_mhrx","id":"3","children":[{"text":"news_releases","id":"54","cls":"file","leaf":"true"},{"text":"bios","id":"10","cls":"file","leaf":"true"}],"cls":"folder"},{"text":"investors","id":"41","cls":"file","leaf":"true"}],"cls":"folder"},{"text":"Home","id":"38","cls":"file","leaf":"true"}]}]
    It renders fine as a tree, however when I drag and drop the beforemove event that has the alert() call never does anything. If I change the event to click, then it fires when I click one, but the moving does nothing. I'm wondering if it's due to the data structure with the 'children' sub-array. It renders fine, but maybe that's keeping it from being a proper node? I'm trying to just load all the data at once rather than have additional queries to load the child data.

  2. #2
    Ext User
    Join Date
    Nov 2007
    Posts
    7
    Vote Rating
    0
    aleks_raiden is on a distinguished road

      0  

    Exclamation


    I have this problems and its resolved: recreate TreePanel before update Tree node

Thread Participants: 1