Git Product home page Git Product logo

Comments (7)

Alyar666 avatar Alyar666 commented on August 18, 2024

Hello,

Currently, our TreeList returns only explicitly selected nodes. We have plans to improve our API to simplify getting all selected rows.

Use the solution from the TreeList - How to get all selected nodes in recursive selection mode example.

from devextreme.

genachka avatar genachka commented on August 18, 2024

@Alyar666 Please reopen this as that's not what I'm asking for. The sample provided shows how to get the selected. I'm specifically referring to the callback onSelectionChanged that should provide an array of all the selected / unselected keys when you select / unselect the parent whereas currently it only provides the parent key for e.currentSelectedRowKeys / e.currentDeselectedRowKeys when using the newly recursive (i.e. selection: {mode: 'multiple', showCheckBoxesMode: 'always', recursive: true})

from devextreme.

Alyar666 avatar Alyar666 commented on August 18, 2024

Hi,

To the onSelectionChanged event handler come only explicitly selected/unselected keys to make the behavior consistent when a remote and a local data source are used. Currently, you will need to iterate through nodes manually.

>> The sample provided shows how to get the selected

The sample provided shows how to get selected child nodes by parent key. You can get selected/unselected child nodes via the getAllSelectedNodes function in the onSelectionChanged event handler.

Here is a complete sample for your convenience: https://codepen.io/anon/pen/MrpNoz

from devextreme.

genachka avatar genachka commented on August 18, 2024

@Alyar666 the sample as a workaround helps thanks. Understand current functionality, am requesting enhancement to it for the recursive to be useful with the onSelectionChanged event. I would think that as an enhancement it would return an array of children and array of arrays for each level child of child, etc.

from devextreme.

GoshaFighten avatar GoshaFighten commented on August 18, 2024

@genachka

As @Alyar666 stated, we had plans to improve our API to get all selected node. We did this in the #2492 PR. In version 18.1, you will be able to use the getSelectedRowKeys method to do this:

treeListInstance.getSelectedRowKeys("all")

As for extending onSelectionChanged event parameters, currently, we don't have plans to do this. But, we implemented the forEachNode method in the #2726 PR so that you don't need to write your own code to iterate through all node children. Instead, you are able to simply pass a callback function to the method to specify what you need to do with a node. You can use this method for your task. So, the onSelectionChanged event handler from Alyar666's sample can be re-written as:

onSelectionChanged: function (e) {
    var currentSelectedKeys = [],
        currentDeselectedKeys = [];
    e.component.forEachNode(e.currentSelectedRowKeys.map((key) => e.component.getNodeByKey(key)), node => {
        currentSelectedKeys.push(node.key);
    });
    e.component.forEachNode(e.currentDeselectedRowKeys.map((key) => e.component.getNodeByKey(key)), node => {
        currentDeselectedKeys.push(node.key);
    });
    $("#selectionInfo").html(
        "Current selected keys = " + currentSelectedKeys.join(", ") +
        "<br/> Current deselected keys = " + currentDeselectedKeys.join(", ")
    );
}

The forEachNode method will be available in versions 17.2.6 and 18.1.

from devextreme.

genachka avatar genachka commented on August 18, 2024

@GoshaFighten thanks for the update, clarification and example! I'll give it a shot in 17.2.5 and am eagerly awaiting to try it out in 18.1!

from devextreme.

sometimesElen avatar sometimesElen commented on August 18, 2024

Hi @genachka,
We've published our 18.1.0-sprint.2 results. As you see, we added the getSelectedRowKeys overload. But we changed the modes in #2839 . Use the following code to get all selected TreeList nodes
treeListInstance.getSelectedRowKeys("includeRecursive")

from devextreme.

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.