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

  • Home
  • SEARCH
  • 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 8587321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:32:30+00:00 2026-06-11T22:32:30+00:00

I am using EXT JS for a simple tree that will show a single

  • 0

I am using EXT JS for a simple tree that will show a single directory and its contents. For whatever reason I have gone through all of their examples and am not able to replicate what I want. I want to create a JSON object based on the directory structure so it can be fed into the EXT JS Tree.

Here is my script that opens up the directory, creates the parent node then attempts to create the child nodes. Inside this directory are just .xml files. I have gotten it to work with opening the directory and just creating nodes for the files but it doesnt show the parent or root level and loses the nifty collapsing affect.

Here is my code:

if($handler = opendir($dir."/$market_desc"))
          {

          while (($sub = readdir($handler)) !== FALSE)
          {
              if ($sub !== "." && $sub !== ".." && $sub !== ".svn")
              {
                  if(is_file($dir."/$market_desc/".$sub))
                  {
                      $subDir[] = array(
                       'text' => $sub,
                       'id'   => $sub,
                       'checked' => false,
                       'leaf' => true,
                       'cls'  => 'file'
                           );
                  }
              }

          }

           $listDir[] = array(
           'text' => $market_desc,
           'id'   => $market_desc,
           'checked' => false,
           'cls'  => 'folder',
           'children' => array($subDir)
        );


          closedir($handler);
          unset($handler);

The directory structure only goes 1 level deep with some files at the root level followed by a number of directories that also contain files but never going more than 1 level down.

I am a php back-end developer by trade so I apologize for my noobness when it comes to javascript and the correct formation of this JSON needed by EXT

  • 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-06-11T22:32:31+00:00Added an answer on June 11, 2026 at 10:32 pm

    After some trial and error I have this PHP script in the correct format for EXT JS. It will open the directory and build the nested array which can the be json_encoded and sent to EXT JS Tree for rendering

              // Get market specific features and make nodes
          if($handler = opendir($dir."/$market_desc"))
          {
              while (($sub = readdir($handler)) !== FALSE)
              {
                  if ($sub !== "." && $sub !== ".." && $sub !== ".svn")
                  {
                      if(is_file($dir."/$market_desc/".$sub))
                      {
                                    $subDir[] = array(
                                    'text' => $sub,
                                    'id'   => $sub,
                                    'checked' => false,
                                    'leaf' => true,
                                    'parent' => $market_desc,
                                    'children' => NULL,
                                    'cls'  => 'file'
                                    );
                      }
    
                  }
    
              }
                              $listDir[] = array(
                              'text' => $market_desc,
                              'id'   => $market_desc,
                              'checked' => false,
                              'cls'  => 'folder',
                              'parent' => NULL,
                              'expanded' => true,
                              'children' => $subDir
                                  );
    
    
              closedir($handler);
              unset($handler);
          }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using ext.net with asp.net, I'm generating a tree using server side code: Ext.Net.Node
I am using Ext.Net 1.3 with ASP.NET 4.0 application. I have few Ext ComboBox
This the model that I want to create using json file Ext.define('Users', { extend:
I'm using extjs and just trying to solve a simple problem: I have a
I'm an Ext veteran but have a few rather simple mobile apps i need
I have posted this question on the Ext-GWT forums, I am just hoping that
I'm trying to get all .c files in a directory tree using nftw with
hi i am using django app engine patch i have set up a simple
I am new to ExtJs(using EXT js 4 ), I am trying out simple
I am using an Ext DateField like this in date.js ( I only have

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.