public static void LoadGridConfiguration(RadGrid pRdg, long pIdGruppoUtente, bool loadDefaultString = false) { GridSettingsPersister gsp = new GridSettingsPersister(pRdg); using (DMWEntities context = new DMWEntities()) { long idControlloAspx = (from ctrl in context.ControlliAspx where (ctrl.NomeControllo == pRdg.ID) select ctrl.IdControlloAspx).SingleOrDefault(); if (idControlloAspx == 0) { throw new Exception("Grid Control not defined in database [ControlliAspx]"); } var stringaConfigurazioneGruppoUtente = (from pg in context.ProprietaGriglie where (pg.IdControlloAspx == idControlloAspx) && (pg.IdGruppoUtente == pIdGruppoUtente) select new { pg.StringaConfigurazione, pg.StringaConfigurazioneDefault }).FirstOrDefault(); if (loadDefaultString) { gsp.LoadSettings(stringaConfigurazioneGruppoUtente.StringaConfigurazioneDefault); } else { gsp.LoadSettings(stringaConfigurazioneGruppoUtente.StringaConfigurazione); } } }protected void btnPersistConfiguration_Clicked(object sender, EventArgs e) { MachinaWeb.ServerControls.RadPageView paginaConComboIdGruppoUtente = (MachinaWeb.ServerControls.RadPageView)((System.Web.UI.Control)MachinaWeb.ServerControls.Utility.FindControlType((Control)sender, typeof(MachinaWeb.ServerControls.RadPageView))); MachinaWeb.ServerControls.RadGrid gridUC = (MachinaWeb.ServerControls.RadGrid)((System.Web.UI.Control)MachinaWeb.ServerControls.Utility.FindControlType((Control)sender, typeof(MachinaWeb.ServerControls.RadGrid))); long selectedGU = long.Parse( ((RadComboBox)paginaConComboIdGruppoUtente.FindControl("blccmbGruppoUtente")).SelectedValue ); //MessageBox.ShowTelerik(Page, this, "Configurazione salvata (Id Gruppo " + blccmbGruppoUtente.SelectedValue + ")"); string gridName = gridUC.ID; using (DMWEntities context = new DMWEntities()) { long idControlloAspx = (from ctrl in context.ControlliAspx where (ctrl.NomeControllo == gridName) select ctrl.IdControlloAspx).SingleOrDefault(); if (idControlloAspx == 0) { throw new Exception("Grid Control not defined in database [ControlliAspx]"); } var propGriglia = (from pg in context.ProprietaGriglie where (pg.IdControlloAspx == idControlloAspx) && (pg.IdGruppoUtente == selectedGU) select pg).FirstOrDefault(); GridSettingsPersister gsp = new GridSettingsPersister(gridUC); string stringaConfigurazioneVista = gsp.SaveSettings(); if (propGriglia == null) { //Creates row in database [Proprieta griglie] ProprietaGriglie pgNew = new ProprietaGriglie() { IdGruppoUtente = selectedGU, NomeGriglia = gridName, StringaConfigurazione = stringaConfigurazioneVista, IdControlloAspx = idControlloAspx, DataCreazione = DateTime.Now, DataAggiornamento = DateTime.Now, IdUtente = ((SessionInformation)Session["sessionData"]).IdUtente }; context.ProprietaGriglie.AddObject(pgNew); context.SaveChanges(); } else { //Updates row [Proprieta griglie] var pg = (from pgUpd in context.ProprietaGriglie where (pgUpd.IdControlloAspx == idControlloAspx) && (pgUpd.IdGruppoUtente == selectedGU) select pgUpd).Single(); pg.StringaConfigurazione = stringaConfigurazioneVista; context.SaveChanges(); } } }public partial class Configurazione_VisteTabellari : System.Web.UI.Page{ private RadGrid rdg = new RadGrid(); protected void Page_Init(object sender, EventArgs e) { hfdIdCultura.Value = ((SessionInformation)Session["sessionData"]).IdCultura.ToString(); } protected override void InitializeCulture() { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(((SessionInformation)Session["sessionData"]).Cultura); System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(((SessionInformation)Session["sessionData"]).Cultura); base.InitializeCulture(); } protected void Page_Load(object sender, EventArgs e) { //string resource_ModificareLayoutTabella = (string)GetGlobalResourceObject("Resource", "MessaggioModificaLayoutTabella"); using (DMWEntities context = new DMWEntities()) { if (!String.IsNullOrEmpty(hdfIdMascheraSelezionata.Value)) { long idMascheraSelezionata = long.Parse(hdfIdMascheraSelezionata.Value); string urlVisioneTabellare = (from masc in context.Maschere where masc.IdMaschera == idMascheraSelezionata select masc.UrlControlloVistaTabellare).Single<string>(); try { RadGridStabilimenti uc = ((RadGridStabilimenti)LoadControl(urlVisioneTabellare)); uc.Type = CommonParameters.RadGridType.Configurazione; pnlVistaTabellare.Controls.Clear(); pnlVistaTabellare.Controls.Add(uc); } catch (Exception) { } //Loads stringa configurazione di default per la grid //RadGrid gridUC = ((IUserControlGrid)pnlVistaTabellare.Controls[0]).GetGrid(); //if (!Page.IsPostBack) //{ // try // { // Utility.LoadGridConfiguration(gridUC, ((SessionInformation)Session["sessionData"]).IdGruppoUtente, true); // } // catch (ArgumentNullException) // { // } //} string selectedGU = (((SessionInformation)Session["sessionData"]).IdGruppoUtente).ToString(); blccmbGruppoUtente.SelectedValue = selectedGU; blccmbGruppoUtente.DataBind(); //gridUC.DataBind(); } } } protected void rtsPagina_TabClick(object sender, RadTabStripEventArgs e) { rts_Pagina.SelectedIndex = e.Tab.Index; rmp_Pagina.SelectedIndex = e.Tab.Index; } protected void RadGridVisioniTabellari_ItemCreated(object sender, GridItemEventArgs e) { ////Sets filter's textbox width //if (e.Item is GridFilteringItem) //{ // //30px di differenza rispetto alla larghezza della colonna // GridFilteringItem gridFilteringItem = (GridFilteringItem)e.Item; // ((TextBox)(gridFilteringItem["NomeMaschera"]).Controls[0]).Width = Unit.Pixel((int)(900 - CommonParameters.GridFilterWidthDistances)); //} } protected void btnLoadConfiguration_Click(object sender, EventArgs e) { RadGrid gridUC = ((IUserControlGrid)pnlVistaTabellare.Controls[0]).GetGrid(); string gridName = gridUC.ID; GridSettingsPersister gsp = new GridSettingsPersister(gridUC); Utility.LoadGridConfiguration(gridUC, long.Parse(blccmbGruppoUtente.SelectedValue)); }}<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %><%@ Register Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" TagPrefix="telerik" %><script runat="server" language="vbscript"> Protected Sub btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn.Click Dim div As New HtmlGenericControl("div") div.Style("height") = "300px" div.Style("border") = "1px solid #f00" Dim edt As New RadEditor() edt.Height = Unit.Pixel(300) edt.OnClientLoad = "function(editor,args){ editor.set_mode(1); }" div.Controls.Add(edt) pnl.Controls.Add(div) End Sub</script><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title></head><body> <form id="form1" runat="server"> <asp:ScriptManager runat="server" /> <asp:Panel runat="server" ID="pnl"> <asp:Button runat="server" ID="btn" Text="Load Controls" /> </asp:Panel> <telerik:RadAjaxManager runat="server" DefaultLoadingPanelID="loading"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="pnl"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="pnl" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <telerik:RadAjaxLoadingPanel runat="server" ID="loading"> Loading... </telerik:RadAjaxLoadingPanel> </form></body></html>setTimeout(function() { editor.set_mode(1); }, 100);UpdateCommand="UPDATE [tblClass] SET [ClassName] = @ClassName, [FK_CityID] = 2 %> WHERE [PK_ClassID] = @original_PK_ClassID" <telerik:RadGrid ID="RadGrid1" GridLines="None" runat="server" AllowAutomaticDeletes="True" Skin="Windows7" AllowAutomaticInserts="True" PageSize="10" AllowAutomaticUpdates="True" AllowPaging="True" AutoGenerateColumns="False" DataSourceID="SessionDataSource1" OnItemUpdated="RadGrid1_ItemUpdated" OnItemDeleted="RadGrid1_ItemDeleted" OnItemInserted="RadGrid1_ItemInserted" OnDataBound="RadGrid1_DataBound"> <PagerStyle Mode="NextPrevAndNumeric" /> <MasterTableView Width="100%" CommandItemDisplay="TopAndBottom" DataKeyNames="PK_ClassID" DataSourceID="SessionDataSource1" HorizontalAlign="NotSet" AutoGenerateColumns="False"> <Columns> <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn"> <ItemStyle CssClass="MyImageButton" /> </telerik:GridEditCommandColumn> <%-- <telerik:GridBoundColumn DataField="PK_ClassID" HeaderText="ID" SortExpression="PK_ClassID" UniqueName="PK_ClassID" ColumnEditorID="GridTextBoxColumnEditor1"> </telerik:GridBoundColumn>--%> <telerik:GridBoundColumn DataField="ClassName" HeaderText="Class Name" SortExpression="ClassName" UniqueName="ClassName" ColumnEditorID="GridTextBoxColumnEditor2"> </telerik:GridBoundColumn> <telerik:GridDropDownColumn DataField="FK_CityID" DataSourceID="SqlDataSource1" HeaderText="City" ListTextField="City" ListValueField="PK_CityID" UniqueName="PK_CityID" ColumnEditorID="GridDropDownColumnEditor1"> </telerik:GridDropDownColumn> <telerik:GridButtonColumn ConfirmText="Delete this product?" ConfirmDialogType="RadWindow" ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn"> <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" /> </telerik:GridButtonColumn> </Columns> <EditFormSettings ColumnNumber="2" CaptionDataField="FK_CityID" CaptionFormatString="Bearbeiten der Klasse {0}" InsertCaption="Neue Klasse"> <FormTableItemStyle Wrap="False"></FormTableItemStyle> <FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle> <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" BackColor="White" Width="100%" /> <FormTableStyle CellSpacing="0" CellPadding="2" Height="110px" BackColor="White" /> <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle> <EditColumn ButtonType="ImageButton" InsertText="Insert Order" UpdateText="Update record" UniqueName="EditCommandColumn1" CancelText="Cancel edit"> </EditColumn> <FormTableButtonRowStyle HorizontalAlign="Right" CssClass="EditFormButtonRow"></FormTableButtonRowStyle> </EditFormSettings> </MasterTableView> <ClientSettings> <ClientEvents OnRowDblClick="RowDblClick" /> </ClientSettings> </telerik:RadGrid> <telerik:GridTextBoxColumnEditor ID="GridTextBoxColumnEditor1" runat="server" TextBoxStyle-Width="200px" /> <telerik:GridTextBoxColumnEditor ID="GridTextBoxColumnEditor2" runat="server" TextBoxStyle-Width="150px" /> <telerik:GridDropDownListColumnEditor ID="GridDropDownColumnEditor1" runat="server" DropDownStyle-Width="110px" /> <telerik:GridNumericColumnEditor ID="GridNumericColumnEditor1" runat="server" NumericTextBox-Width="40px" /> <telerik:RadWindowManager ID="RadWindowManager1" runat="server"></telerik:RadWindowManager> <br /> <asp:SqlDataSource ID="SessionDataSource1" runat="server" ConnectionString="Server=.\SQLExpress ;Database=IntraIBZ;Trusted_Connection=True;" ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM [tblClass]" DeleteCommand="DELETE FROM [tblClass] WHERE [PK_ClassID] = @original_PK_ClassID" InsertCommand="INSERT INTO tblClass(ClassName, FK_CityID) VALUES (@ClassName, @FK_CityID)" UpdateCommand="UPDATE [tblClass] SET [ClassName] = @ClassName, [FK_CityID] = 2 %> WHERE [PK_ClassID] = @original_PK_ClassID" OldValuesParameterFormatString="original_{0}" ConflictDetection="CompareAllValues"> <DeleteParameters> <asp:Parameter Name="original_PK_ClassID" Type="Int32" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="ClassName" Type="String" /> <asp:Parameter Name="FK_CityID" Type="Int32" /> <asp:Parameter Name="original_PK_ClassID" Type="Int32" /> <asp:Parameter Name="PK_CityID" Type="Int32" /> </UpdateParameters> <InsertParameters> </InsertParameters> </asp:SqlDataSource> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Server=.\SQLExpress ;Database=IntraIBZ;Trusted_Connection=True;" ProviderName="System.Data.SqlClient" SelectCommand="SELECT [PK_CityID], [City] FROM [tblCity]"> </asp:SqlDataSource> <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> <script type="text/javascript"> function RowDblClick(sender, eventArgs) { sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical()); } </script> </telerik:RadCodeBlock>[Exception: Invalid column type: "TreeListTemplateColumn".]
Telerik.Web.UI.RadTreeList.CreateColumnByType(String columnType) +184
Telerik.Web.UI.TreeListColumnsCollection.System.Web.UI.IStateManager.LoadViewState(Object state) +350
Telerik.Web.UI.RadTreeList.LoadViewState(Object savedState) +97
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +183
System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221
System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221
System.Web.UI.Page.LoadAllState() +312
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1661
This also happens when "a lot" of columns has been added and I try to collapse a section.
I guess it's pretty easy to reproduce if you just fiddle a bit with the following page / code.
Try for instance to expand "A", then click "Month", and try to collapse "A".
Or just click "Month" then "Quarter".
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TreeViewTimeline.aspx.cs" Inherits="Web20.TreeViewTimelineTelerik.TreeViewTimeline" EnableEventValidation="false" %> <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <div> <asp:LinkButton ID="QtrButton" runat="server" Text="Quarter" OnClick="QtrButtonClicked" /> <asp:LinkButton ID="MonthButton" runat="server" Text="Month" OnClick="MonthButtonClicked" /> <div id="tbl-container"> <telerik:RadTreeList runat="server" ID="treeList" Skin="Vista" AutoGenerateColumns="False" OnInit="treeListInit" DataKeyNames="ID" ParentDataKeyNames="Parent" OnItemCommand="treeListItemCommand" > <Columns> <telerik:TreeListTemplateColumn UniqueName="Name" HeaderText="Navn" > <HeaderStyle /> <ItemStyle /> <ItemTemplate> <asp:TextBox runat="server" ID="NameTextBox" Text='<%# Eval("Name") %>' /> </ItemTemplate> </telerik:TreeListTemplateColumn> </Columns> </telerik:RadTreeList> </div> </div> </form> </body> </html> using System; using System.Collections.Generic; using System.Web.UI; using System.Web.UI.WebControls; using Telerik.Web.UI; namespace Web20.TreeViewTimelineTelerik { public partial class TreeViewTimeline : System.Web.UI.Page { public string Mode { get { return ViewState["mode"] as string ?? "Quarter"; } set { ViewState["mode"] = value; } } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindList(); } } private void BindList() { var list = new[] { new Item {ID = "A", Name = "A", Parent = "", Periods = new Dictionary<string, Period> {{"Q1", new Period {Name = "Q1"}}, {"Feb", new Period {Name="1/10"}}}} , new Item {ID = "B", Name = "B", Parent = ""} , new Item {ID = "A.A", Name = "A.A", Parent = "A", Periods = new Dictionary<string, Period> {{"Q2", new Period { Name = "Qtr 2"}}, {"Q3", new Period {Name="Qty 3"}}, {"Mar", new Period{Name="2/10"}} }} }; treeList.DataSource = list; treeList.DataBind(); } protected void treeListItemCommand(object sender, TreeListCommandEventArgs e) { if (e.CommandName == RadTreeList.ExpandCollapseCommandName) { ResetColumns(); } } protected void treeListInit(object sender, EventArgs e) { InitColumns(); } private void InitColumns() { switch(Mode) { case "Quarter": string[] quarters = new[] {"Q1", "Q2", "Q3", "Q4"}; foreach(string quarter in quarters) treeList.Columns.Add(new TreeListTemplateColumn{UniqueName = quarter, HeaderText = quarter, ItemTemplate = new PeriodTemplate(quarter)}); break; case "Month": string[] months = new[] {"Jan", "Feb", "Mar", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Des"}; foreach(string month in months) treeList.Columns.Add(new TreeListTemplateColumn { UniqueName = month, HeaderText = month, ItemTemplate = new PeriodTemplate(month) }); break; } } private void ResetColumns() { RemoveDynamicColumns(); InitColumns(); BindList(); } private void RemoveDynamicColumns() { for(int i = treeList.Columns.Count - 1; i>=1; i--) treeList.Columns.RemoveAt(i); } protected void QtrButtonClicked(object sender, EventArgs e) { Mode = "Quarter"; ResetColumns(); } protected void MonthButtonClicked(object sender, EventArgs e) { Mode = "Month"; ResetColumns(); } } public class PeriodTemplate : ITemplate { private readonly string quarter; public PeriodTemplate(string quarter) { this.quarter = quarter; } public void InstantiateIn(Control container) { Label label = new Label(); label.EnableViewState = false; label.ID = quarter + "Label"; Item dataItem = (Item)DataBinder.GetDataItem(container.BindingContainer); if (dataItem != null && dataItem.Periods != null) { if (dataItem.Periods.ContainsKey(quarter)) label.Text = dataItem.Periods[quarter].Name; } container.Controls.Add(label); } } public class Item { public string ID { get; set; } public string Parent { get; set; } public string Name { get; set; } public Dictionary<string, Period> Periods { get; set; } } public class Period { public string Name { get; set; } } }Hope you guys can help. :)
Lars-Erik
Telerik.Web.UI.RadComboBox.prototype._removeDropDown = function() { var slide = this.get_dropDownElement().parentNode; slide.parentNode.removeChild(slide); if (this._disposeChildElements) $telerik.disposeElement(slide); if (!$telerik.isSafari) slide.outerHTML = null; this._dropDownElement = null; };