Hi, how should I fix these breaking changes?
- CompareNodesTagCommand has been removed.
- RadTreeNodeCollection.Find has been removed.
- RadTreeNode.DataBoundItem is read-only. Is there a way to change it manually in unbound mode?
- TreeNodeUI has been removed.
Thanks.
- CompareNodesTagCommand has been removed.
- RadTreeNodeCollection.Find has been removed.
- RadTreeNode.DataBoundItem is read-only. Is there a way to change it manually in unbound mode?
- TreeNodeUI has been removed.
Thanks.
3 Answers, 1 is accepted
0
Accepted
Hello Zensell,
If you want to use the old Command aproach here is implementation of removed CompareNodesTagCommand command:
2) The new Find command can be used implementing a different search callback function:
3) DataBoundItem is used only in bound mode and can not be changed at run time. You can use the Tag property to reference your custom business object related to RadTreeNode object.
4) TreeNodeUI element is changed with TreeNodeElement that supports full customization. More information you can refer in our online documentation or in our Examples application, section TreeView >> Customize. All the best,
Julian Benkov
the Telerik team
1) You can use new Find method of RadTreeView control for this behavior. Here is a small example:
private
object
tagKey;
private
bool
FindByTag(RadTreeNode node)
{
if
(node.Tag !=
null
)
{
IComparable comparer = node.Tag
as
IComparable;
if
((comparer !=
null
&& comparer.CompareTo(tagKey) == 0) ||
node.Tag.Equals(key))
{
return
true
;
}
}
return
false
;
}
private
void
radButton1_Click(
object
sender, EventArgs e)
{
RadTreeNode nodeByTag =
this
.radTreeView1.Find(
this
.FindByTag);
}
If you want to use the old Command aproach here is implementation of removed CompareNodesTagCommand command:
public
class
CompareNodesTagCommand : CommandBase
{
public
override
object
Execute(
params
object
[] settings)
{
if
(settings.Length > 1 &&
this
.CanExecute(settings[0]))
{
RadTreeNode node = settings[0]
as
RadTreeNode;
object
key = (settings[1]
as
IList)[0];
if
(node !=
null
&& node.Tag !=
null
)
{
IComparable comparer = node.Tag
as
IComparable;
if
((comparer !=
null
&& comparer.CompareTo(key) == 0) ||
node.Tag.Equals(key))
{
return
node;
}
}
}
return
null
;
}
public
override
bool
CanExecute(
object
parameter)
{
if
(
typeof
(RadTreeNode).IsAssignableFrom(parameter.GetType()))
{
return
true
;
}
return
base
.CanExecute(parameter);
}
}
2) The new Find command can be used implementing a different search callback function:
private
void
radButton1_Click(
object
sender, EventArgs e)
{
RadTreeNode nodeByName =
this
.radTreeView1.Find(
this
.FindByKey);
RadTreeNode nodeByText =
this
.radTreeView1.Find(
this
.FindByText);
}
private
string
key;
private
bool
FindByKey(RadTreeNode node)
{
if
((
this
.key ==
null
) || (node.Name ==
null
))
{
return
false
;
}
if
(
this
.key.Length != node.Name.Length)
{
return
false
;
}
return
(
string
.Compare(
this
.key, node.Name,
true
, CultureInfo.InvariantCulture) == 0);
}
private
string
text;
private
bool
FindByText(RadTreeNode node)
{
if
((
this
.text ==
null
) || (node.Text ==
null
))
{
return
false
;
}
if
(
this
.text.Length != node.Text.Length)
{
return
false
;
}
return
(
string
.Compare(
this
.text, node.Text,
true
, CultureInfo.InvariantCulture) == 0);
}
3) DataBoundItem is used only in bound mode and can not be changed at run time. You can use the Tag property to reference your custom business object related to RadTreeNode object.
4) TreeNodeUI element is changed with TreeNodeElement that supports full customization. More information you can refer in our online documentation or in our Examples application, section TreeView >> Customize. All the best,
Julian Benkov
the Telerik team
0
MP
Top achievements
Rank 1
answered on 25 May 2011, 08:02 PM
Dear Telerik,
We were using the TreeNodeUI.AssociatedNode property and now are not sure how to access this property with the new release. We had used the following code to find out which node was being double-clicked. Please advise.
foreach
(TreeNodeUI treeNodeUI
in
this
.radTreeView1.TreeViewElement.Items)
{
if
(treeNodeUI.AssociatedTreeNode == radTreeView1.SelectedNode)
{
uiNode = treeNodeUI;
break
;
}
}
if
(uiNode !=
null
)
{
if
(uiNode.BoundingRectangle.Contains(e.Location))
{
//do stuff
}
}
0
Hello MP,
Do not hesitate to contact us if you have further questions or issues.
Best wishes,
Julian Benkov
the Telerik team
For this scenario you can use following code snippet:
TreeNodeElement nodeElement =
this
.radTreeView1.TreeViewElement.GetElement(
this
.radTreeView1.SelectedNode);
if
(nodeElement !=
null
&& nodeElement.BoundingRectangle.Contains(e.Location))
{
//TO DO
}
Do not hesitate to contact us if you have further questions or issues.
Best wishes,
Julian Benkov
the Telerik team