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 6746867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:22:24+00:00 2026-05-26T12:22:24+00:00

im trying to build a treepanel (or just a simple tree i just need

  • 0

im trying to build a treepanel (or just a simple tree i just need it to work) and load it with data from database

here is my code to build the tree

  var objHandler = new Interact();

  var treestore = new  Ext.data.TreeStore ( {

     root:{
            id:'root_node',
            nodeType:'async',
            text:'Root'            
        },
     proxy:{            
            type:'ajax',            
            url:'myUrl'
        }


});     


    function ReadTree() {
            try {
                objHandler.ReadAssets(function (serverResponse) {
                    if (serverResponse.error == null) {
                        var result = serverResponse.result;

                        if (result.length > 2) {
                            treestore.load(Ext.decode(result));//TreeStore does not inherit from Ext.data.Store and thus does not have a loadData method. Both TreeStore and Store inherit from Ext.data.AbstractStore which defines a load method only. Therefore TreeStore has a load method
                           }
                    }
                    else {
                        alert(serverResponse.error.message);
                    }
                }); //eo serverResponse
            } //eo try
            catch (e) {
                alert(e.message);
            }
        }




 var AssetTree = Ext.create('Ext.tree.Panel', {
    title: 'Asset Tree',
    width: 200,
    height: 150,
    store: treestore,
   // loader: new Ext.tree.TreeLoader({    url: 'myurl'  }),

    columns: [
                { xtype: 'treecolumn',text : 'First Name',  dataIndex :'Title'}/*,
                {text : 'Last',  dataIndex :'Adress'},
                {text : 'Hired Month',  dataIndex :'Description'}*/
             ],
    autoscroll : true

}); 

     ReadTree();

im using jayrock : http://code.google.com/p/jayrock/

Interact.ashx.cs :

public class Interact : JsonRpcHandler
{

    [JsonRpcMethod()]
    public string ReadAssets()
     {
        // Make calls to DB or your custom assembly in project and return the result in JSON format. //This part is making custom assembly calls.

        clsDBInteract objDBInteract = new clsDBInteract();
        string result;
        try
         {
            result = objDBInteract.FetchAssetsJSON();
         }
        catch (Exception ex)
         {
            throw ex;
         }
        return result;

     }

clsDBInteract.cs :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using Extensions;

namespace WebBrowser
{
    public class clsDBInteract
    {

        SqlConnection dbConn = new SqlConnection("server=***********; user id = *****; password = ******; Database=*******");

        /////// data to fill assets grid
        public DataSet FetchAssetsDS()
        {
            DataSet ds = new DataSet();
            try
              {
                SqlCommand sqlCommand = new SqlCommand("select Title, adress, Description from table");
                sqlCommand.Connection = dbConn;
                sqlCommand.CommandType = CommandType.Text;
                SqlDataAdapter sda = new SqlDataAdapter(sqlCommand);
                dbConn.Open();
                sda.Fill(ds);
                if (sqlCommand.Connection.State == ConnectionState.Open)
                    {
                    dbConn.Close();
                    }
                //ds = sqlCommand.ExecuteNonQuery();
              }
           catch (Exception ex)
             {
                 throw ex;
             }
          return ds;
       }//eo FetchAssetsDS

       public string FetchAssetsJSON()
        {
            string result = string.Empty;
            try
               {
                DataSet ds = FetchAssetsDS();
                result = ds.ToJSONString(); // This method will convert the contents on Dataset to JSON format;
               }
            catch (Exception ex)
             {
                 throw ex;
             }
            return result;
        }//eo FetchAssetsJSON




    }//eo clsDBInteract
}

I dont have any error, but the panel is empty, i tested and i can read the data in the readtree function..so i guess the problem would be in the store maybe or the loading

its been more than two weeks that im trying to pull this off
any help would be appreciated

P.S: im using ExtJs4 with c# .net

thanks

  • 1 1 Answer
  • 1 View
  • 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-26T12:22:24+00:00Added an answer on May 26, 2026 at 12:22 pm

    i solved this by creating my own type (no jayrock)

    my tree model and store:

    Ext.define('TreeModel', {
    extend: 'Ext.data.Model',
    fields: [
            { name: 'text' },
            { name: 'id' },
            { name: 'descr' }
    
        ]
    });
    
    window.TreeStore = Ext.create('Ext.data.TreeStore', {
    model: 'TreeModel',
    root: Ext.decode(obj.TreeToJson()),
    proxy: {
        type: 'ajax'
    },
    sorters: [{
        property: 'leaf',
        direction: 'ASC'
    }, {
        property: 'text',
        direction: 'ASC'
    }]
    });
    

    my class:

       public class TreeItem
    {
        public string text { get; set; }
    
        public int id { get; set; }
    
        public string descr { get; set; }
    
        public string expanded { get; set; }
    
        public string leaf { get; set; }
    
        public List<TreeItem> children { get; set; }
    
    }
    

    then i get my data and fill my tree like this

    public string TreeToJson()
        {  
    List<TreeItem> child = new List<TreeItem>();
            for (int i = 0; i < n; i++)
            {
                child.Add(new TreeItem() { text = t.AssetTree()[i].Item1, id = t.AssetTree()[i].Item2, ip = t.AssetTree()[i].Item3, descr = t.AssetTree()[i].Item4, expanded = "false", leaf = "true" });
            }
    
            TreeItem tree = new TreeItem() { text = "my root", id = 0, expanded = "true", leaf = "false", children = child };
    }
    

    hope it helps someone

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

Sidebar

Related Questions

I'm trying to build a treepanel (or just a simple tree I just need
I am trying to build a dynamic tree. I am getting my data from
I have a std::vector< tr1::shared_ptr<mapObject> > that I'm trying build from data contained in
trying to build a query from a few tables here, and getting stumped on
I was trying Build For Archiving application (from Titanium Mobile) with xCode 4.4, but
I'm trying build a method which returns the shortest path from one node to
Trying to build sslsniff on a RHEL 5.2 system here. When compiling sslsniff on
Trying to build Xuggler under Windows. Xuggler is core native code functions wrapped into
Trying to build dynamic output from json and using jq/template tmpl display rows/columns. Somehow
Trying to build the following simple example #include <boost/python.hpp> using namespace boost::python; tuple head_and_tail(object

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.