After the following controller code is executed, and the javascript code
$(
'#TreeView').data('tTreeView').bindTo([result]);
is executed, the value of the root node is, lets say 600.
// Create the root node, which is the workspace within the site
tvItem0 =
new TreeViewItemModel();
tvItem0.Text = ws.Name;
tvItem0.Value = ws.ID.ToString();
tvItem0.Expanded =
true;
tvItem0.LoadOnDemand =
true;
tvItem0.Enabled =
true;
foreach (PageContent pc in ws.Children)
{
tvItem =
new TreeViewItemModel();
tvItem.Text = pc.Name;
tvItem.Value = pc.ID.ToString();
tvItem.Expanded =
true;
tvItem.LoadOnDemand =
true;
tvItem.Enabled =
true;
tvItem0.Items.Add(tvItem);
}
return new JsonResult { Data = tvItem0 };
But, when the tree appears and the root node is clicked on, the root value is incorrect; it is the value of the first child under the root node, say 519. The following javascript code is used to retrieve the value of the node:
var nodeSelected = $(e.item).closest('.t-item').find(':input[name*="Value"]').val();
Can the controller code above that creates the tree nodes be used to do client side binding? It just has a root node and children below it.
The code is using version 2010.1.309 of the MVC TreeView control, jquery 1.4.2, running under Microsoft Vista Business N, Service Pack 2.
Thanks in advance,
Eugene
7 Answers, 1 is accepted
Upgrading to Q1 2010 SP1 (assembly version 2010.1.416) should address this problem. Then please use the provided getItemValue JavaScript to obtain the node value:
var nodeSelected = treeView.getItemValue($(e.item));
Regards,
Atanas Korchev
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.
You can download from here.
Regards,
Atanas Korchev
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.
Microsoft JScript runtime error: Object doesn't support this property or method, whereas using a variable first as in var treeview = $('#TreeView').data('tTreeView'); treeview.getItemValue($(e.item)); did indeed work.
Sincerely and thanks again,
Eugene
This error is natural as $('#TreeView') is a jQuery object whereas $('#TreeView').data('tTreeView') is the TreeView client side object (totally different thing).
All the best,
Atanas Korchev
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.