Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 834563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:41:28+00:00 2026-05-15T04:41:28+00:00

I asked this question in the Ext JS forums, but I received no responses,

  • 0

I asked this question in the Ext JS forums, but I received no responses, so I am asking here.

I have a TreePanel (code below) that uses a TreeLoader and an AsyncTreeNode. In my API method specified by the TreeLoader’s dataUrl, I return a JSON array to populate the tree.

This works great, of course. However, I need to return an additional item–an integer–in addition to the array, and I need to display that value somewhere else in my UI. Is this possible? If not, what else would be a good solution?

Here’s the code I have currently:

tree = new Ext.tree.TreePanel({
  enableDD: true,
  rootVisible: false,
  useArrows: true,

  loader: new Ext.tree.TreeLoader({
    dataUrl: '/api/method'
  }),

  root: new Ext.tree.AsyncTreeNode()
});

I want to return one single integer value for the entire response–not per node. Basically my API method will create a database record, and I need to return a value from that database record.

EDIT Thanks to Mike, I have solved this problem. I extended the Ext.tree.TreeLoader class like so:

TreeLoaderWithMetaData = Ext.extend(Ext.tree.TreeLoader, {
  processResponse : function(response, node, callback) {
    var json = response.responseText;

    try {
      var o = eval("("+json+")");
      metaData = o.shift();

      node.beginUpdate();

      for(var i=0, len=o.length; i<len; i++) {
        var n = this.createNode(o[i]);

        if (n) {
          node.appendChild(n);
        }
      }

      node.endUpdate();

      if(typeof callback == "function") {
        callback(this, node);
      }
    }
    catch (e) {
      this.handleFailure(response);
    }
  }
});

And then I can reference variables in the meta data like public members: metaData.my_variable1, metaData.my_variable2. My AJAX data from the server just has an extra array item:

[{"my_variable1":"value1","my_variable2":"value2"},{"id":"node1","text":"Node 1",children:[{"id":"node1nodeA","text":"Node 1 Node A"}]]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T04:41:29+00:00Added an answer on May 15, 2026 at 4:41 am

    You need to override the processResponse function in TreePanel and then you’ll be able to return whatever format JSON you’d like:

    From the ExtJS forums:
    http://www.extjs.com/forum/showthread.php?32772-Passing-JSON-string-from-Grails-to-populate-TreePanel

    The code at the bottom of that thread will help you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have asked this question before and it seemed that the code I was
(I asked this question in another way , and got some interesting responses but
I originally asked this question on RefactorMyCode , but got no responses there... Basically
I originally asked this question , but in finding an answer, discovered that my
This question might have asked here number of times . After doing some google
I asked this question on the jQueryUI forums, but got no response. I've created
I recently asked this question , but after some of the responses and some
I have been asked this question by a colleague that should we always include
I asked this question before, Here however I think I presented the problem poorly,
I asked this question a while back but now I'm looking to implement an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.