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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:05:23+00:00 2026-06-04T02:05:23+00:00

i have created a tree select that shows a dijit.tree in the dropdown. Now

  • 0

i have created a tree select that shows a dijit.tree in the dropdown. Now I do not want the user to select a folder even if it is empty. User should only be able to select the end nodes or leaves. dijit.tree treats all empty folders as leafs. how do I get that sorted?

  • 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-04T02:05:24+00:00Added an answer on June 4, 2026 at 2:05 am

    You need to override the _onClick or setSelected methods. This gets complicated if you use the multi-parental model ForestStoreModel.

    See fiddle.net

    Try doing as such, this will only work for select multiple false:

        getIconClass: function fileIconClass(item, nodeExpanded) {
            var store = item._S,
                get = function() {
                    return store.getValue(item, arguments[0]);
                };
            // scope: dijit.Tree
            if (item.root || get("isDir")) {
    
                if (!item || this.model.mayHaveChildren(item) || get("isDir")) {
                    return (nodeExpanded ? "dijitFolderOpened" : "dijitFolderClosed");
                } else {
                    return "dijitLeaf";
                }
    
            } else {
    
                return "dijitLeaf";
    
            }
        },
        onClick: function(item, treeNode, e) {
    
            var store = item._S,
                get = function() {
                    return store.getValue(item, arguments[0]);
                };
            if (get("isDir")) this.set("selectedItems", []);
        }
    

    Adapt as you see fit, matching your json data – in particular the isDir, the above works on a sample of json like this

    {
        identifier: 'id',
        label: 'foo',
        items: [
            {
            id: 'item1',
            foo: 'file1',
            isDir: false},
        {
            id: 'item2',
            foo: 'emptyDir',
            isDir: true},
        {
            id: 'item3',
            foo: 'dir',
            isDir: true,
            children: [
                {
                id: 'item3_1',
                foo: 'fileInDir',
                isDir: false}
            ]}
        ]
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For a new project I have created a local folder tree with empty Visual
I have a binary tree class that is created with a root node and
I have stored procedure that I created in MySQL and want PHP to call
I have two tree, which contains nodes, after I've created them, I take all
I want to create tree structure using web service. I have used bottom up
I have a python script that is trying to create a directory tree dynamically
I'm trying to create an expression tree dynamicly. Let asume that I have two
I want to be able to create a tree view that can get its
I have the following table: CREATE TABLE [dbo].[Tree]( [AutoID] [int] IDENTITY(1,1) NOT NULL, [Category]
I have a Masterpage that has Treeview. You can select some nodes there. Based

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.