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

[Solved] Binding treeview to JSON object inconsistently hides expansion arrows

0 Answers 23 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
David
Top achievements
Rank 1
David asked on 17 Jul 2012, 02:46 PM
I've inherited an application which binds data to a Telerik Treeview (using Telerik.Web.Mvc version 2011.1.315.235 - I know it's outdated, don't have a lot of choice to upgrade at the moment) by essentially doing the following in JS (I've removed a lot, but I think this is the essentials):

var jsonObject= [ ];
for (var i = 0; i < items.length; i++) {
    jsonObject.push({ Text: "<span>" + items[i] + "</span>", Value: items[i], Enabled: true, Expanded: false, LoadOnDemand: true, Encoded: false, Checkable: true });
}
treeview.bindTo(jsonObject);

Sometimes (~80-90% of the time) everything works fine: the treeview is bound to my ~30 top-level items, they're all expandable, and expanding them loads the appropriate children (approx 20,000 total items throughout the entire tree). However sometimes after the tree populates (within a second or two) the expansion arrows all disappear. The HTML is then:

<span class="t-icon t-plus" style="display: none; "></span>

(modifying this using Firebug or Chrome to remove the style restores the node to it's expected state: clicking the expansion icon correctly loads the children)

In telerk.treeview.min.js (I only have the minified version on hand for this project, and am reluctant to assume any freshly-downloaded normal file will be the exact same version) I see:

bindTo:function(d){this.dataBind(this.element,d)},dataBind:function(d,e){d=a(d);var f=d.find("> .t-group"),i=d.find("> div > .t-icon");hasData=e.length>0;if(e.length==0){i.remove();f.remove();return}else{if(i.length==0){d.find("> div").prepend('<span class="t-icon t-plus" />')}}
...

Which I'm guessing is at least the right ballpark, but I'm still lost as to what's changing during some of these binds to occasionally hide the expansion icons. The data being bound should be identical when the binding works correctly as when it hides the expansion icons.

Can anyone shed some light on this?






Tags
TreeView
Asked by
David
Top achievements
Rank 1
Share this question
or