Wijmo grid selecting parent node should select child node(s) too

Posted by: mmurugesan on 6 February 2020, 6:59 pm EST

    • Post Options:
    • Link

    Posted 6 February 2020, 6:59 pm EST

    Hi Team

    When I click on a item in my wijmo hierarchical grid, if there is any child items for that clicked then the child items also should be auto selected. I’m having code like below which selects only the clicked item but not sure how to proceed it with children.

    this.myGrid.select(-1, -1);

    this.myGrid.rows.forEach(row => {

    if (row.dataItem.label === e.toElement.innerText.trim()) {

    row.isSelected = true;

    if (row.dataItem.Children) {

                    }
                }
                else {
                    row.isSelected = false;
                }
    

    please advice.

    Thanks in advance.

  • Posted 7 February 2020, 3:12 am EST

    Hi Manoharan,

    You will need to handle the selectionChanged event of the FlexGrid and iterate over the child rows, if any, selecting them on the way. Please refer to the code snippet and the sample below:

    theGrid.selectionChanged.addHandler(function(s, e) {
      s.selectedRows = [];
      var row = s.rows[e.row];
      row.isSelected = true;
      if(row.hasChildren) {
        var curRowIdx = row.index + 1, childRow = s.rows[curRowIdx++];
        while(childRow && childRow.level > row.level) {
          childRow.isSelected = true;
          childRow = s.rows[curRowIdx++];
        }
      }
    });
    

    https://stackblitz.com/edit/js-krhahn

    Regards,

    Ashwin

  • Posted 7 February 2020, 10:19 am EST

    This trick worked. Thanks Aswin.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels