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

Node image resize

6 Answers 149 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
richard
Top achievements
Rank 1
richard asked on 18 Dec 2011, 12:47 AM
Hi
I undertand I can set width or max-width of node image using css:

#ExploreTreeView img

{

max-width:16px;

max-height:16px

}


I would like to be able to set the image max width programatically though as it needs to be different for certain nodes.
I noticed there is a style property with RadTadTreeNode, I tried this:

C#
newNode.Style.Value= "img {max-width:22px}";
I really don't know if this syntax is correct, but this doesn't work for me.

Can anyone suggect the right way for me to define the image width/max-width programatically?


Thanks
Richard

 

6 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 19 Dec 2011, 05:38 AM
Hello,

Try the following way if you are using <asp:image>.
CS:
protected void Page_Load(object sender, EventArgs e)
{
  if (!Page.IsPostBack)
   {
     RadTreeView1.DataBind();
     RadTreeNode node = RadTreeView1.Nodes[0];
     Image img11 = (Image)node.FindControl("img1");
     img11.Width = Unit.Pixel(500);
   }
}

If you are using ImageUrl property of RadTreeview, then you can simply add the following CSS to set the width.
CSS:
<style type="text/css">
 .rtImg
  {
    width:10px !important;
  }
</style>

Thanks,
Princy.
0
richard
Top achievements
Rank 1
answered on 03 Jan 2012, 04:36 PM
Thanks for your help Princy,

unfortunately the solution changes the image size for every tree node, but I need to be able to set the dimensions on a node by node basis, with a variable width.

Any ideas?

Best Regards
Richard
0
Dimitar Terziev
Telerik team
answered on 05 Jan 2012, 09:27 AM
Hello Richard,

I've prepared a sample page which I believe would fit your requirements. A different CSS class is applied for different nodes based on custom attribute.

Regards,
Dimitar Terziev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
richard
Top achievements
Rank 1
answered on 05 Jan 2012, 10:24 AM
Hello Dimitar,
many thanks for your help.

I think I should explain what I am trying to do:-

I want to allow a user to right click a node and allow : choose or upload the icons for expand and collapse, choose or upload the node icon, additionally allow specify icon sizes - for the selected node.  The expand and collapse icons need to be inheritted from that that node onwards.

The details for the node will be held in an xml file or possibly in a database, if no details a re found for the node then apply default attributes.

Perhaps a good approach would be to generate the css file at runtime,  maybe I should be looking at  'dynamic css'.

Regards
Richard
0
Dimitar Terziev
Telerik team
answered on 09 Jan 2012, 12:29 PM
Hi Richard,

The scenario that you want to achieve is quite complex, but what I could think of as an approach will be to dynamically modify the existing CSS using jQuery once an image is uploaded for a specific node.

Regards,
Dimitar Terziev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
richard
Top achievements
Rank 1
answered on 09 Jan 2012, 02:58 PM
Hello Dimitar
thanks for your advice.I will give this a go.

Best Regards
Richard
Tags
TreeView
Asked by
richard
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
richard
Top achievements
Rank 1
Dimitar Terziev
Telerik team
Share this question
or