Giter VIP home page Giter VIP logo

Comments (11)

avtokey avatar avtokey commented on July 1, 2024 11

please get some example to get parent value(Id) in items. I think, It's very important for all developers.

Parent (value: 1) -- I need this value, but I think this component doesn't have such functionality.
--Child 1 (value: 2)
--Child 2 (value: 3)

from ngx-treeview.

leovo2708 avatar leovo2708 commented on July 1, 2024

Question 1: using TreeviewEventParser like in my example 5 https://leovo2708.github.io/ngx-treeview/. You can get list of checked from root to leaf.

Question 2: Yes, you can. You can update checked of your TreeviewItem object. But it will not update checked of parent, you must do this yourself. You should write a helper to handle this.

from ngx-treeview.

nghiado avatar nghiado commented on July 1, 2024

Thanks for quick resposne @leovo2708.
Yes, #1, I was thinking about create a custom TreeviewEventParser to return a flat list of selected items.
About #2, can you give an example?
What I was thinking is in TreeviewItemComponent

onCheckedChange = (skipChildrenCheck) => {
        const checked = this.item.checked;
        if (!_.isNil(this.item.children)&& !skipChildrenCheck) {
            this.item.children.forEach(child => child.setCheckedRecursive(checked));
        }

        this.checkedChange.emit(checked);
    }
    onChildCheckedChange(child: TreeviewItem, checked: boolean, skipParentUpdate) {
        if (this.item.checked !== checked && !skipParentUpdate) {
            let itemChecked = true;
            for (const tmpChild of this.item.children) {
                if (!tmpChild.checked) {
                    itemChecked = false;
                    break;
                }
            }

            this.item.checked = itemChecked;
        }

        this.checkedChange.emit(checked);
    }

I tried to override the onCheckedChange and onChildCheckedChange but the component is not exported from the lib so not so sure how I can achieve this.

from ngx-treeview.

leovo2708 avatar leovo2708 commented on July 1, 2024

If I support option {disabled: true, checked: false} for item ReactJS, does it rescue you?

from ngx-treeview.

nghiado avatar nghiado commented on July 1, 2024

from ngx-treeview.

leovo2708 avatar leovo2708 commented on July 1, 2024

I think you can use itemTemplate. It can help you.

from ngx-treeview.

nghiado avatar nghiado commented on July 1, 2024

@leovo2708 I need a way to emit this event this.checkedChange.emit(checked); using itemTemplate without calling onCheckedChange and onChildCheckedChange.
I think this requires a minor change in TreeviewItemComponent and TreeviewItemTemplateContext.

from ngx-treeview.

leovo2708 avatar leovo2708 commented on July 1, 2024

Please help me to create pull request. Thanks.

from ngx-treeview.

leovo2708 avatar leovo2708 commented on July 1, 2024

Published in new version 1.2.2.

from ngx-treeview.

arunkumar1811 avatar arunkumar1811 commented on July 1, 2024

Hi,
"selectedChange" event has been fired when selecting Parent but the $event array is empty. But the expected would be event array with Parent node value.
I guess the problem is with binding the selected node in ngmodel

Its working as expected when I select child nodes. I'm using the latest verion 1.2.3.

Parent and child nodes can be selected independently by setting decoupleParentChild= true in the config.

from ngx-treeview.

rwasan avatar rwasan commented on July 1, 2024

same issue please let me know if it's fixed

from ngx-treeview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.