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

[Solved] Treeview Client-Side Databinding "Expanded" Not Working

1 Answer 116 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.
Dylan Lin
Top achievements
Rank 1
Dylan Lin asked on 27 Sep 2010, 05:18 AM
Hi,

I found that if I bind the data to the treeview in the client-side, the "expaned" property won't work.
Look at the following simple code snippet:
<div class="t-widget t-treeview t-reset" id="TreeView"></div>
<script type="text/javascript">
    jQuery(function () {
        jQuery('#TreeView').tTreeView({
            onDataBinding: onDataBinding
        });
    });
 
    function onDataBinding(e) {
        var treeview = $('#TreeView').data('tTreeView');
        var jsonObject;
 
        if (e.item == treeview.element) {
            jsonObject = [
            { Text: "Product 1", Expanded: false,
                Items: [
                    { Text: "Product 4",
                        Items: [
                        { Text: "Product 6", Value: 6 },
                        { Text: "Product 7" }
                    ]
                    }
                ]
            }
        ];
 
            treeview.bindTo(jsonObject);
        }
    }
</script>

The result is in the attachement "result.png":

1 Answer, 1 is accepted

Sort by
0
Accepted
Alex Gyoshev
Telerik team
answered on 27 Sep 2010, 12:41 PM
Hello Dylan Lin,

Thank you for notifying us of this problem. It has been fixed for the service pack, which will be released this week. Before that, you can patch your source in these steps:
  1. in getGroupHtml, replace
        .catIf(' style="display:none"', isExpanded === false)
    with
        .catIf(' style="display:none"', isExpanded !== true)
  2. in getItemHtml, replace
        .catIf(' t-plus', !item.Expanded)
        .catIf(' t-minus', item.Expanded)

    with
        .catIf(' t-plus', item.Expanded !== true)
        .catIf(' t-minus', item.Expanded === true)

Sincerely yours,
Alex Gyoshev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Dylan Lin
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Share this question
or