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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:12:35+00:00 2026-05-22T20:12:35+00:00

I have a dojo.data.ItemFileWriteStore object with items which contain a ‘children’ attribute, which in

  • 0

I have a dojo.data.ItemFileWriteStore object with items which contain a ‘children’ attribute, which in turn contains an array of children items. I’m storing a tree, and I need to fetch the leaf nodes from this tree. I have written a fetch method but it will not work giving it a query of “children: []” How can I fetch the data store items that have a children.length of 0 (the leaf nodes)? A blank array without adding attributes such as ‘leaf’ : bool to my items would obviously work, but I’d rather not have the extra attribute.

dojo.require(dojo.data.ItemFileWriteStore);

// A tree node with no children, these are the kind I want returned
// from the query!
var rootItem = {
        children: []
};

var treeStore = new dojo.data.ItemFileWriteStore({
    data: {
        items: [rootItem]
    }
}); 

//when dojo reaches one of its inner filtering methods
//there is a point where it calls dojo.some() to see
//which elements in the array to return which match the
//given items attribute, this is where it fails

treeStore.fetch({
    query: {children: []},
    queryOptions: {deep: true},
    onComplete: function(leafItems) {
        // All the items with no children here...
    }
});

I also tried nesting a function for the attribute to no avail:

treeStore.fetch({
    query: {
        children: function(store, item){
                return store.getValue(item, 'children').length == 0;
        }
    },
    queryOptions: {deep: true},
    onComplete: function(leafItems) {
        // All the items with no children here...
    }
});
  • 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-22T20:12:36+00:00Added an answer on May 22, 2026 at 8:12 pm
    baseStore.fetch({
                    query:{id:'*'},
                    onComplete:function(a,b,c){
                        dojo.forEach(a,function(item,index){
                            console.log(item.children);
                        })
                    }
                })
    

    if item.children is undefined then those are the “item” that you want.
    If you don’t want to use a separate fetch for this operation alone, then use a private property called _arrayOfAllItems on the store to get a flat data store, upon which you can do the same condition mentioned above.

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

Sidebar

Related Questions

I'd like to change the data in my dojo.data.ItemFileWriteStore. Currently I have... var rawdataCacheItems
Is it possible to make another dojo.data.ItemFileWriteStore out of the properties of items from
I have: dojo.xhrGet({ url:/data/js/1/markers.js, handleAs:javascript, load: function(r){ dojo.forEach(placemarks, function(item) { Which works fine in
I have a dojo.xhrGet that return an correct array of object : <script type=text/javascript>
I have written an app using dojo that allocates a lot of data during
I have this data : { identifier: id, idAttribute:id, label: date, items: [ {
I have a login.jsp page which contains a login form. Once logged in the
I have a web page displaying data using dojo datagrid. Sometimes, users need to
I have this string, which is generated by dojo.toJson() function: {page:accommodation task=viewList,language:undefined} When decoding
I have a dojo.data.ItemFileReadStore as follows: var partyStore = new dojo.data.ItemFileReadStore({ id: 'partyStore', data:

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.