jQuery UI Widgets Forums TreeGrid TreeGrid How to get the parent node?

This topic contains 3 replies, has 2 voices, and was last updated by  Hristo 8 years, 2 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • TreeGrid How to get the parent node? #90513

    MatcherAny
    Participant

    In the API, I did not find the current node to get the method of the parent node。

    TreeGrid How to get the parent node? #90522

    Hristo
    Participant

    Hello MatcherAny,

    Could you give more details, which case you want to get the parent node?
    For example, if you want to get a parent, when selecting a row, you could use this approach:

    $('#treeGrid').on('rowSelect', function (event) {
    	var args = event.args;
    	var row = args.row;
    	var hasParent = !!row.parent;
    	if (hasParent) {
    		console.log(row.parent);
    	}
    });

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

    TreeGrid How to get the parent node? #90680

    MatcherAny
    Participant

    I use Google Translate

    Thank you very much Hristo
    Use ‘rowSelect’ to get the current row, But how to get the details of the parent node?
    The use of loops is not elegant ……

    var parentNode = null;
            var rows = $scope.treeGridSettings.apply('getRows');
            for (var i = 0; i < rows.length; i++) {
                var node = rows[i];
                if (selectedNode.parent == node.id) {
                    parentNode = node;
                }
            }
    TreeGrid How to get the parent node? #90692

    Hristo
    Participant

    Hello Matthias,

    I would like to suggest you try the simple example with rowSelect event.
    As the example that I mentioned before var row = args.row; – “row” is an object with “parent” property.
    You could show this object in the console and will see more details.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.