Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    How to add checkboxes to a tree?

    I have a Tree in a TreeGrid and would like to add grandchildren to the Tree that are checkboxes. How can I do this? Currently, when I add children to the Tree, they appear with what looks like a document icon.

    Here is my TreeGrid and Tree:

    var tgrid = isc.TreeGrid.create({
    ID: "tgrid",
    width: "100%",

    fields: [{
    name: "title",
    title: "current "
    }],

    data: isc.Tree.create({
    ID: "currenttree",
    root: {
    children: [{
    title: "treeFolder",
    canDrag: false,
    isFolder: true,
    children: [{
    }]
    }]
    }
    })
    });

    I add children to the Tree. I am trying to get these children to appear as checkboxes.

    let thetree = tgrid.getData(); // I get the tree from the treegrid
    let treenodes = thetree.getAllNodes(); // tree nodes

    // here I try to add a checkbox child to the folder I have under the tree, but it appears not as a checkbox but as a document
    thetree.add(({
    name: "treeGrandchild",
    type:"checkbox",
    isFolder: false,
    title: "grandchild",
    }),treenodes[0]);
    Last edited by erik2000; 19 Jun 2020, 11:14. Reason: changed children to grandchildren

    #2
    You might selectionStyle:"checkbox" (note also the support for cascading selection).

    If you still need to control the icons at that point (which will appear *in addition to* the checkbox), search for "icon" in the TreeGrid docs, there are many ways to control the icons (in particular see getIcon()).

    Comment

    Working...
    X