This is a migrated thread and some comments may be shown as answers.

[Solved] Treeview - Check children only if parent node is expanded

1 Answer 78 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ryan
Top achievements
Rank 1
Ryan asked on 18 Feb 2011, 04:00 AM
Hi folks,

Two questions. Firstly, I'm using this JavaScript currently to check all children.

function onTreeDataBound(e) {
    $('#AjaxTreeView').find("li:has(ul)")
                .find('> div > .t-checkbox :checkbox')
                .bind('click', function (e) {
                    var isChecked = $(e.target).is(':checked');
                    var treeView = $($(e.target).closest('.t-treeview')).data('tTreeView');
                    var checkboxes = $(e.target).closest('.t-item')
                                                .find('> ul > li > div > .t-checkbox :checkbox');
                    $.each(checkboxes, function (index, checkbox) {
                        $(checkbox).attr('checked', isChecked ? true : false);
                        treeView.checkboxClick(e, checkbox);
                    });
                });
}

What I would like, though, is for the children to be checked only when the item is expanded (only let items the user can see, to be checked). How would I accomplish this?

Second, is there any way to save all expanded nodes (even if it was just the first level) in a cookie, and re-expand them next load? I am using LoadOnDemand/AJAX binding, so the solution I saw already about setting a cookie wouldn't work in this case.

Thanks!

1 Answer, 1 is accepted

Sort by
0
Ryan
Top achievements
Rank 1
answered on 22 Feb 2011, 06:09 AM
Tags
General Discussions
Asked by
Ryan
Top achievements
Rank 1
Answers by
Ryan
Top achievements
Rank 1
Share this question
or