Results 1 to 3 of 3

Thread: Help: Sending Ext.tree data back to server (ColdFusion)

  1. #1
    Ext User
    Join Date
    Mar 2007
    Vote Rating

    Default Help: Sending Ext.tree data back to server (ColdFusion)

    Hi everyone,

    I'm new to YUI, JSON, and a fairly novice JavaScripter - I usually deal with the server side of things and am comfortable in CFMX.

    I'm re-writing an app, and want to use the (awesome!) drag-and-drop tree control to maintain various hierarchies within the database. I have found a few examples in the forums, and has kludged together something that kind of works (See below...)

    		 * Ext - JS Library 1.0 Alpha 3 - Rev 4
    		 * Copyright(c) 2006-2007, Jack Slocum.
    			// shorthand
    			var Tree = Ext.tree;
    			var tree = new Tree.TreePanel('tree-div', {
    				loader: new Tree.TreeLoader({dataUrl:'boo.cfm'}),
    				containerScroll: true
    			tree.on("enddrag", function(tree) {
    				// create a simplified node hierarchy that can be JSONified
    				function simplifyNodes(node) {
    					var resultNode = {};
    					var kids = node.childNodes;
    					var len = kids.length;
    					for (var i = 0; i < len; i++) {
    						resultNode[kids[i].id] = simplifyNodes(kids[i]);
    					return resultNode;
    				// JSON-encode our tree
    				var encNodes = Ext.encode(simplifyNodes(tree.root));
    				// send it to the backend to save
    					'action=treeUpdate&nodes=' + encodeURIComponent(encNodes)
    			// set the root node
    			var root = new Tree.AsyncTreeNode({
    				text: '#arguments.nodeTitle#',
    			// render the tree
    With this I can create the tree I need from my hier, allow the user to assign new parent nodes, and also allow the user to reorder the nodes, then send the current state of the hierarchy back to the server where it waits to be processed if everything checks out and the user completes the process...

    My problem starts with the "simplifyNodes()" function - which creates a JSON string that decodes into a structure of nested structures (objects) in CFMX (I'm using jsonDecode() from

    Structure keys in CF are unordered - so while I can determine if a node has a new parent, I can not determine the sort order easily, without custom parsing the JSON string (which does maintain the proper key order as an ordered list of sorts).

    My questions are:

    1. Is there an easier method to send the current tree state back via JSON string rather than recursive looping over node.childNodes? (I've looked thru the API guide and can not find anything - but it seems almost impossible that it doesn't exist somewhere I can simply "dump" the current data to the JSON encoder before sending it back to my handler...)

    2. Barring that, can anyone hold my hand a little and help me with the "simplifyNodes()" function so it returns a JSON string that includes required arrays - to keep the nodes in the proper order when decoded by CFMX jsonDecode()... I'm new to JSON, and unsure of the formatting required. (And I'm too lazy to go learn it right now...)

    What I am guessing is that if the JSON is created correctly, it will jsonDecode() into a complex object of nested structures with arrays... I can work with that...

    Thanks in advance,


  2. #2
    Ext User
    Join Date
    Mar 2007
    Vote Rating

    Default I should have noted...

    I'll be away for a few days - but I wanted to post before I lost my train of thought - I will be back next Tuesday to continue conversating with whoever is kind enough to reply to my request!

    Thank you,


  3. #3
    Ext User
    Join Date
    Mar 2007
    Vote Rating

    Default Help: Sending Ext.tree data back to server (ColdFusion)

    Hi there

    i m looking to build something similar that u mentioned in ur post, also with coldfusion. did you have any joy? I m having problems getting my tree to display.

    any help or advice appreciated!


Similar Threads

  1. EditorGrid + Store and how to send back modified data
    By alfiewong in forum Ext 2.x: Help & Discussion
    Replies: 11
    Last Post: 20 May 2010, 10:03 AM
  2. JSON data in coldfusion
    By dangerzone in forum Ext 1.x: Help & Discussion
    Replies: 9
    Last Post: 23 Nov 2007, 3:08 PM
  3. Error sending xml from grid to Server?
    By franklt69 in forum Ext 1.x: Help & Discussion
    Replies: 0
    Last Post: 21 Feb 2007, 1:37 PM
  4. Sending multiple tree node values to server.
    By in forum Ext 1.x: Help & Discussion
    Replies: 2
    Last Post: 10 Jan 2007, 12:22 AM
  5. onCellUpdated and sending updates back to the server
    By judah in forum Ext 1.x: Help & Discussion
    Replies: 3
    Last Post: 4 Oct 2006, 11:52 PM

Posting Permissions

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