Hi,
I'm trying to change the ForeColor of a node client side. I have managed to do this by altering the innerHTML but this has ugly side effects. Do anyone have a better way?
What I really want to do is to change a node from dimgray to the original color determined by the skin.
Best Regards
Daniel
I'm trying to change the ForeColor of a node client side. I have managed to do this by altering the innerHTML but this has ugly side effects. Do anyone have a better way?
What I really want to do is to change a node from dimgray to the original color determined by the skin.
Best Regards
Daniel
6 Answers, 1 is accepted
0

Shinu
Top achievements
Rank 2
answered on 29 Dec 2009, 07:00 AM
Hello Daniel,
Try the following code in order to change the forecolor of node from client side.
javascript:
-Shinu.
Try the following code in order to change the forecolor of node from client side.
javascript:
function changeColor() { |
var tree = $find('<%= RadTreeView1.ClientID %>'); |
var node = tree.findNodeByText('Root RadTreeNode1'); // get the node |
node.get_element().style.color = "red"; // change the color |
} |
-Shinu.
0

Tobias
Top achievements
Rank 1
answered on 29 Dec 2009, 08:46 AM
Hi again,
thanks for the help but it didn't work.
I set the forecolor from code behind to illustrate that a node is deleted. The complete code to change the color is below according to your sample. It is in the rightclick meny of a context menu. I have investigated the complete style property and it is completly empty. It contains a lot of properties but all is either "", 0 or false.
Best Regards
Daniel
thanks for the help but it didn't work.
I set the forecolor from code behind to illustrate that a node is deleted. The complete code to change the color is below according to your sample. It is in the rightclick meny of a context menu. I have investigated the complete style property and it is completly empty. It contains a lot of properties but all is either "", 0 or false.
function ClientContextMenuItemClicked(sender, eventArgs) { |
var node = eventArgs.get_node(); |
var item = eventArgs.get_menuItem(); |
var menu = item.get_menu(); |
var command = item.get_attributes().getAttribute("Command"); |
switch (command) { |
case "Undelete": |
//Set the color according to style (remove dimgray color) |
node.get_element().style.color = "red"; //Test |
node.set_contextMenuID('m_RadTreeViewContextMenuAdd'); |
break; |
} |
} |
Best Regards
Daniel
0
Accepted
Hello,
The ForeColor is applied on the text element (rtIn). To clear it use the following code:
Happy holidays!
Greetings,
Tsvetomir Tsonev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
The ForeColor is applied on the text element (rtIn). To clear it use the following code:
node.get_textElement().style.color =
""
;
// Clear ForeColor
Happy holidays!
Greetings,
Tsvetomir Tsonev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0

Tobias
Top achievements
Rank 1
answered on 29 Dec 2009, 11:33 AM
Thanks,
It worked perfektly.
Have a great New Year!
Daniel
It worked perfektly.
Have a great New Year!
Daniel
0

Igor
Top achievements
Rank 1
answered on 03 Feb 2011, 01:58 AM
Hello
I'm having similar problem. I'm using function bellow to and new treenode, the function is beeing called by RadWindow OnClientClose event.
when i debug and examine node.get_textElement() the value is alway null
I have also tried node.get_element().style.color =
Any help will be appreciated.
I'm having similar problem. I'm using function bellow to and new treenode, the function is beeing called by RadWindow OnClientClose event.
function
AddNode(args) {
// Get tree view object
treeView = $find(args.TreeViewID);
treeView.trackChanges();
//Instantiate a new client node
var
node =
new
Telerik.Web.UI.RadTreeNode();
//Set node text
node.set_text(args.NodeName);
//Set node value
node.set_value(args.NodeValue);
//Set enable Context Menu
node.set_enableContextMenu(
true
);
//Set context menu id
node.set_contextMenuID(
"AddEditDeleteDisableContexMenu"
)
node.get_textElement().style.color =
"gray"
;
//Set allow edit
node.set_allowEdit(
true
)
//Set allow drag
node.set_allowDrag(
false
)
//Add the new node as the child of the selected node or the tree view if no node is selected
var
parent = parent = treeView.findNodeByValue(args.ParentID);
parent.get_nodes().add(node);
//Expand the parent if it is not the tree view
if
(parent != treeView && !parent.get_expanded())
parent.set_expanded(
true
);
treeView.commitChanges();
node.select();
return
false
;
}
when i debug and examine node.get_textElement() the value is alway null
I have also tried node.get_element().style.color =
"gray"
;
Any help will be appreciated.
0
Hi Igor,
Could you please tell us whether you're using templates? Can you send us the definition of the treeview?
Kind regards,
Yana
the Telerik team
Could you please tell us whether you're using templates? Can you send us the definition of the treeview?
Kind regards,
Yana
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.