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

Telerik.Web.UI.RadTreeView._preInitialize fails

1 Answer 143 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
tomas
Top achievements
Rank 1
tomas asked on 18 Feb 2009, 01:30 PM
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.

using System;  
using System.Data;  
using System.Configuration;  
using System.Linq;  
using System.Web;  
using System.Web.Security;  
using System.Web.UI;  
using System.Web.UI.HtmlControls;  
using System.Web.UI.WebControls;  
using System.Web.UI.WebControls.WebParts;  
using System.Xml.Linq;  
using System.Xml;  
 
using Telerik.Web.UI;  
using System.Collections.Generic;  
 
namespace CB.LayerPresentation.Controls.Input  
{  
      
    public class FluTelTreeview : FluTelBase  
    {  
          
        protected DataTable dtData;  
        protected RadTreeView treeView;  
 
        public FluTelTreeview(ScriptManager sm, XmlDocument xdProperties): base(sm,xdProperties)  
        {  
            this.treeView = new RadTreeView();  
            this.treeView.Skin = "Office2007";  
 
            this.Controls.Add(this.treeView);  
 
            // all control properties are set up during this method with help of reflection  
            if (this.xdProperties != null)  
            {  
                this.SetupProperties(this.treeView, null, xdProperties.DocumentElement);  
                this.SetupProperties(this"OuterControl", xdProperties.DocumentElement);  
            }             
        }  
 
        public void SetData(DataTable dtData)  
        {  
            this.dtData = dtData;  
            this.treeView.DataSource = dtData;  
            this.treeView.DataBind();  
        }  
 
        protected override void OnPreRender(EventArgs e)  
        {  
            if (this.sm != null)  
            {  
                if (!this.DesignMode)  
                    sm.RegisterScriptControl(this);  
            }  
            base.OnPreRender(e);  
        }  
 
        protected override void Render(HtmlTextWriter writer)  
        {  
            //base.Render(writer);  
            this.SetInputNameAndControlID();  
 
            if (this.isUpdateRestricted)  
            {  
                writer.WriteLine("<span id=" + this.inputName + "LikeInput>" + this.Value + "</span>");  
            }  
            else 
            {  
 
                if (!this.DesignMode)  
                    sm.RegisterScriptDescriptors(this);  
 
                this.treeView.ID = this.ID + "TreeView";  
 
                // nastavení hodnoty              
          
                // začátek div  
                writer.Write("<div id=" + this.ID + " ");  
 
                //vnitřní control  
                writer.WriteAttribute("innerControlId"this.treeView.ClientID);  
 
                if (this.IsValueDefault)  
                    writer.WriteAttribute("defVal"this.Value);  
 
                if (fr.Mandatory)  
                    writer.WriteAttribute("mandatory", fr.Mandatory.ToString());  
 
                writer.WriteAttribute("isUpdateRestricted", (this.isUpdateRestricted ? "1" : "0"));  
 
                writer.WriteLine(" >");  
 
                // tree view is rendered  
                this.RenderChildren(writer);  
 
                //konec div  
                writer.WriteLine("</div>");  
            }  
 
            //hidden with current value  
            this.RenderHiddenValue(writer,"");  
 
            // hidden with old value  
            if (!this.isUpdateRestricted)  
                this.RenderOldValueHidden(writer);  
        }  
 
 
        protected override IEnumerable<ScriptReference> GetScriptReferences()  
        {  
            ScriptReference reference = new ScriptReference();  
            reference.Path = ResolveClientUrl("scripts/FluTelTreeView.js");  
 
            return new ScriptReference[] { reference };  
        }  
 
        protected override IEnumerable<ScriptDescriptor> GetScriptDescriptors()  
        {  
            ScriptControlDescriptor descriptor = new ScriptControlDescriptor("FluTel.TreeView"this.ID);  
 
            return new ScriptDescriptor[] { descriptor };  
        }  
 
 
    }  
}  
 

1 Answer, 1 is accepted

Sort by
0
tomas
Top achievements
Rank 1
answered on 19 Feb 2009, 01:50 PM
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
Tags
TreeView
Asked by
tomas
Top achievements
Rank 1
Answers by
tomas
Top achievements
Rank 1
Share this question
or