Telerik.Web.UI.RadTreeView._preInitialize fails

2 posts, 0 answers
  1. tomas
    tomas avatar
    139 posts
    Member since:
    Sep 2012

    Posted 18 Feb 2009 Link to this post

    Hello.

    Please, i need a help.

    I am adding TreeView dynamically not directly to form.Controls collection but to another my nested control.

    Is it possible?

    I am getting javascript error in _preInitialize method...

    Thank you very much.

    1 using System;  
    2 using System.Data;  
    3 using System.Configuration;  
    4 using System.Linq;  
    5 using System.Web;  
    6 using System.Web.Security;  
    7 using System.Web.UI;  
    8 using System.Web.UI.HtmlControls;  
    9 using System.Web.UI.WebControls;  
    10 using System.Web.UI.WebControls.WebParts;  
    11 using System.Xml.Linq;  
    12 using System.Xml;  
    13  
    14 using Telerik.Web.UI;  
    15 using System.Collections.Generic;  
    16  
    17 namespace CB.LayerPresentation.Controls.Input  
    18 {  
    19       
    20     public class FluTelTreeview : FluTelBase  
    21     {  
    22           
    23         protected DataTable dtData;  
    24         protected RadTreeView treeView;  
    25  
    26         public FluTelTreeview(ScriptManager sm, XmlDocument xdProperties): base(sm,xdProperties)  
    27         {  
    28             this.treeView = new RadTreeView();  
    29             this.treeView.Skin = "Office2007";  
    30  
    31             this.Controls.Add(this.treeView);  
    32  
    33             // all control properties are set up during this method with help of reflection  
    34             if (this.xdProperties != null)  
    35             {  
    36                 this.SetupProperties(this.treeView, null, xdProperties.DocumentElement);  
    37                 this.SetupProperties(this"OuterControl", xdProperties.DocumentElement);  
    38             }             
    39         }  
    40  
    41         public void SetData(DataTable dtData)  
    42         {  
    43             this.dtData = dtData;  
    44             this.treeView.DataSource = dtData;  
    45             this.treeView.DataBind();  
    46         }  
    47  
    48         protected override void OnPreRender(EventArgs e)  
    49         {  
    50             if (this.sm != null)  
    51             {  
    52                 if (!this.DesignMode)  
    53                     sm.RegisterScriptControl(this);  
    54             }  
    55             base.OnPreRender(e);  
    56         }  
    57  
    58         protected override void Render(HtmlTextWriter writer)  
    59         {  
    60             //base.Render(writer);  
    61             this.SetInputNameAndControlID();  
    62  
    63             if (this.isUpdateRestricted)  
    64             {  
    65                 writer.WriteLine("<span id=" + this.inputName + "LikeInput>" + this.Value + "</span>");  
    66             }  
    67             else 
    68             {  
    69  
    70                 if (!this.DesignMode)  
    71                     sm.RegisterScriptDescriptors(this);  
    72  
    73                 this.treeView.ID = this.ID + "TreeView";  
    74  
    75                 // nastavení hodnoty              
    76           
    77                 // začátek div  
    78                 writer.Write("<div id=" + this.ID + " ");  
    79  
    80                 //vnitřní control  
    81                 writer.WriteAttribute("innerControlId"this.treeView.ClientID);  
    82  
    83                 if (this.IsValueDefault)  
    84                     writer.WriteAttribute("defVal"this.Value);  
    85  
    86                 if (fr.Mandatory)  
    87                     writer.WriteAttribute("mandatory", fr.Mandatory.ToString());  
    88  
    89                 writer.WriteAttribute("isUpdateRestricted", (this.isUpdateRestricted ? "1" : "0"));  
    90  
    91                 writer.WriteLine(" >");  
    92  
    93                 // tree view is rendered  
    94                 this.RenderChildren(writer);  
    95  
    96                 //konec div  
    97                 writer.WriteLine("</div>");  
    98             }  
    99  
    100             //hidden with current value  
    101             this.RenderHiddenValue(writer,"");  
    102  
    103             // hidden with old value  
    104             if (!this.isUpdateRestricted)  
    105                 this.RenderOldValueHidden(writer);  
    106         }  
    107  
    108  
    109         protected override IEnumerable<ScriptReference> GetScriptReferences()  
    110         {  
    111             ScriptReference reference = new ScriptReference();  
    112             reference.Path = ResolveClientUrl("scripts/FluTelTreeView.js");  
    113  
    114             return new ScriptReference[] { reference };  
    115         }  
    116  
    117         protected override IEnumerable<ScriptDescriptor> GetScriptDescriptors()  
    118         {  
    119             ScriptControlDescriptor descriptor = new ScriptControlDescriptor("FluTel.TreeView"this.ID);  
    120  
    121             return new ScriptDescriptor[] { descriptor };  
    122         }  
    123  
    124  
    125     }  
    126 }  
    127  
  2. tomas
    tomas avatar
    139 posts
    Member since:
    Sep 2012

    Posted 19 Feb 2009 Link to this post

    I have already solved this.

    It is not possible to assign treeview id in Render method although it is possible do this in onPrerender method....

    Tom
Back to Top