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

What would stop a node from having its style changed?

6 Answers 26 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 10 May 2010, 07:56 PM
In my experimentation with your treeview I've been able to stylize individual nodes in any way I wished.  Now I've come across a situation where it doesn't seem to work.  The only difference is that the treeview sits in a sliding pane as follows:

        <telerik:RadSplitter ID="radSplitter" runat="server" Height="530" Width="1000" LiveResize="false">
          <telerik:RadPane ID="radPaneLeft" runat="server" Width="22" MinWidth="22" MaxWidth="22" Scrolling="None">
            <telerik:RadSlidingZone ID="radSlidingZone" runat="server" Width="22" ClickToOpen="true" ExpandedPaneId="radSlidingPane" DockedPaneId="radSlidingPane">
              <telerik:RadSlidingPane ID="radSlidingPane" runat="server" Title="Specify Path:" Width="265" ForeColor="Blue"
                                      TabView="ImageOnly" IconUrl="~/Images/hierarchy.gif" OnClientBeforeResize="radSlidingPane_BeforeResize" OnClientExpanded="radSlidingPane_Expanded">
                <div>
                  <asp:Panel ID="panelTree" runat="server" Width="250px" Height="400px" BorderColor="DarkGray" BorderStyle="Groove" BorderWidth="1">
                    <telerik:RadTreeView ID="treeViewMain" runat="server" . . .


Can you envision any situation that would prevent one from stylizing individual nodes?

Robert W.

6 Answers, 1 is accepted

Sort by
0
Nikolay Tsenkov
Telerik team
answered on 11 May 2010, 11:42 AM
Hi Robert,

I think I understand the problem you have, but in order to see what's really happening here, could you please give me a bit more descriptive markup? Lets say a simple TreeView with sample of the styling that you try to apply and of course reproducing and illustrating the problem?

Thanks!

Regards,
Nikolay Tsenkov
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.
0
Robert
Top achievements
Rank 1
answered on 11 May 2010, 10:23 PM
Hi Nikolay,

Thank you for offering to help.  I've been doing some more tests which hopefully will help you identify the problem.

In my situation I have a multi-level treeview.  Please look at the enclosed image and tell me why things work with Approach #1 and not with Approach #2.

In Approach #1, I'm explicitly setting the style of the 2nd-level nodes as I'm creating them.  Here's the code:

  private void PopulateDivisions(RadTreeNode nodeParent)
  {
    DataRow[] rowsFound = Divisions.Select("Mine_Idx_R = " + nodeParent.Value);  // Narrow down selection as per the current Mine
    foreach (DataRow row in rowsFound)
    {
      string name = row["Division_Des"].ToString();
      string idx = row["Division_Idx"].ToString();
      RadTreeNode node = new RadTreeNode(name, idx);
      node.Category = Constants.LocationCategory.Division.ToString();
      node.ToolTip = Constants.LocationCategory.Division.ToString();
      node.ExpandMode = TreeNodeExpandMode.ServerSideCallBack;

      node.Style.Add("font-weight", "bold");

      nodeParent.Nodes.Add(node);
    }
  }
Please look at the 2nd to last line of code.

Now, with Approach #2, here's the start of the code:

  private bool PopulateContracts(RadTreeNode nodeParent)
  {
    nodeParent.Style.Add("font-weight", "bold");

I assure you that "nodeParent" refers to the same 2nd-level nodes as above.  So for some reason, trying to change the style of the node during an ExpandMode event doesn't work.  Though in other modules when I've been trying out your TreeView I'm sure that I was able to change the appearance of particular nodes at will.

Robert

P.S. In all cases the treeview (and other controls) all sit within an ASP.Net UpdatePanel.


0
Nikolay Tsenkov
Telerik team
answered on 12 May 2010, 12:22 PM
Hi Robert,

I have tried to reproduce your problem, but everything works fine in my project and the style is applied either way.
In this situation I can only guess what is wrong with your code and what I find a bit strange is that in Approach #1 you apply the style to the node object:
node.Style.Add("font-weight", "bold");
 
// and then you "add" it to the nodeParent
nodeParent.Nodes.Add(node);

, but in Approach #2 you apply it to the ParentNode instead:
nodeParent.Style.Add("font-weight", "bold");

You have to check if there is a logical error (which nodes are supposed to get the style).

Also I am attaching a simple project which can help you with trying to reproduce the problem. If it's not happening - look for structural differences between your project and mine sample.

Hope this is helpful for you!


Regards,
Nikolay Tsenkov
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.
0
Robert
Top achievements
Rank 1
answered on 12 May 2010, 07:24 PM
Nikolay,

Thank you for creating the demo project.  I've modified it slightly to better emulate what I'm trying to do.  You can download it here: http://pelalusa.com/Downloads/Public/ParentNodeStyleTest.zip   (to save space I removed the Telerik.UI dll but you can quickly replace that)

In my original project my goal was to change the style of a given node if it turned out that it had no children.  One would only know that when one tried to expand the node.  Put another way, the style of the node was changed "after the fact".

Thus, in the example I've provided for you, note that I'm calling "ApplyStyle" after the node has been instantiated in the tree.  But notice that the style does not change.

My question therefore is: Why Not?

Robert
0
Nikolay Tsenkov
Telerik team
answered on 13 May 2010, 02:37 PM
Hi Robert,

The problem in your code is that you set for ExpandMode ServerSideCallback, which is lighter version on ServerSide. If you want to make more of a change than just adding nodes to the currently expanded node you have to use ServerSide expand mode.

E.g.:
protected void Page_Load(object sender, EventArgs e)
{
  if (!Page.IsPostBack)
  {
    RadTreeNode node1 = new RadTreeNode("Node 1");
    node1.ExpandMode = TreeNodeExpandMode.ServerSide;
    RadTreeView1.Nodes.Add(node1);
  }
}
 
 
protected void RadTreeView1_NodeExpand(object sender, RadTreeNodeEventArgs e)
{
  RadTreeNode parentNode = e.Node;
  string parentNodeLabel = parentNode.Text;
  string childNodeLabel = parentNodeLabel + ".1";
 
  RadTreeNode childNode = new RadTreeNode(childNodeLabel);
  childNode.ExpandMode = TreeNodeExpandMode.ServerSide;
  parentNode.Nodes.Add(childNode);
  ApplyStyle(parentNode);
}
 
 
protected void ApplyStyle(RadTreeNode node)
{
  node.Style.Add("font-weight", "bold");
}

Hope this solves your problem!


Regards,
Nikolay Tsenkov
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.
0
Robert
Top achievements
Rank 1
answered on 13 May 2010, 03:50 PM
Nikolay,

The technical reasons for that limitation fascinate me for I can't imagine why I *shouldn't* be able to make such a change.  But alas, changing it to the much slower ServerSide expandmode did indeed allow my code to disable the parent node.

Thank you for your help,

Robert
Tags
TreeView
Asked by
Robert
Top achievements
Rank 1
Answers by
Nikolay Tsenkov
Telerik team
Robert
Top achievements
Rank 1
Share this question
or