or
Hi,
I have problem with hierarchical grid. It loses child tables and data after postback. The problem is with my own component which wraps grid with search textbox control.
If I'm using grid without my component it works correctly:
<telerik:RadGrid ID="grd" runat="server" PageSize="40" DataSourceID="ds1" AllowPaging="true" AllowAutomaticDeletes="true" Width="650px" OnSelectedIndexChanged="userList_ResultGrid_SelectedIndexChanged" OnItemDeleted="userList_ResultGrid_ItemDeleted"> <MasterTableView AutoGenerateColumns="false" DataKeyNames="Id" ClientDataKeyNames="Id" HierarchyLoadMode="Client"> <DetailTables> <telerik:GridTableView DataSourceID="ds2" DataKeyNames="Id" ClientDataKeyNames="Id" Width="100%" Name="UserRoles" AutoGenerateColumns="false" AllowPaging="false" NoDetailRecordsText="No additional roles assigned with this user."> <ParentTableRelation> <telerik:GridRelationFields DetailKeyField="PrimaryUserId" MasterKeyField="Id" /> </ParentTableRelation> <Columns> <telerik:GridBoundColumn DataField="Role.Title" HeaderText="Role" /> </Columns> </telerik:GridTableView> </DetailTables> <Columns> <telerik:GridTemplateColumn HeaderText=""> <HeaderStyle Width="32px" /> <ItemTemplate> <asp:Panel ID="Active" runat="server" Style="height: 16px; width: 16px;" CssClass='<%# (bool)Eval("Active") ? "active-user" : "disabled-user" %>' /> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridBoundColumn DataField="Name" HeaderText="User Name" /> <telerik:GridBoundColumn DataField="Email" HeaderText="Login" /> <telerik:GridButtonColumn ConfirmText="Are you sure you want to delete this user?" ConfirmDialogType="Classic" ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn" ImageUrl="~/Data/Skins/First/Grid/Delete.png"> <HeaderStyle Width="32px" /> <ItemStyle HorizontalAlign="Center" /> </telerik:GridButtonColumn> </Columns> </MasterTableView> <ClientSettings EnablePostBackOnRowClick="true"> <Selecting AllowRowSelect="true" /> <ClientEvents OnRowContextMenu="users_RowContextMenu" /> <Scrolling AllowScroll="True" UseStaticHeaders="True" EnableVirtualScrollPaging="True" /> </ClientSettings> </telerik:RadGrid> <asp:EntityDataSource ID="ds1" runat="server" ContextTypeName="ImpersonatedSecurityEntities" EntitySetName="Users" Where="it.PrimaryUserId is null" /> <asp:EntityDataSource ID="ds2" runat="server" ContextTypeName="ImpersonatedSecurityEntities" EntitySetName="Users" Where="it.PrimaryUserId = @PrimaryUserId"> <WhereParameters> <asp:Parameter Name="PrimaryUserId" DbType="Guid" /> </WhereParameters> </asp:EntityDataSource>I'm using my component more than 1 year without problems but I never defined hierarchy. Now I added hierarchy and it does not work. Here is the code:
<bfo:GridSmartSearch ID="userList" runat="server" ShowAlphabeticPager="true" AlphabeticPagerType="Full" GridSmartSearchType="AjaxManager"> <SearchTextBox EmptyMessage="Type here to search users..." Width="250px" /> <ResultGrid PageSize="40" AllowPaging="true" AllowAutomaticDeletes="true" Width="650px" OnSelectedIndexChanged="userList_ResultGrid_SelectedIndexChanged" OnItemDeleted="userList_ResultGrid_ItemDeleted"> <MasterTableView AutoGenerateColumns="false" DataKeyNames="Id" ClientDataKeyNames="Id" HierarchyLoadMode="Client"> <DetailTables> <telerik:GridTableView DataSourceID="dsA" DataKeyNames="Id" ClientDataKeyNames="Id" Width="100%" Name="UserRoles" AutoGenerateColumns="false" AllowPaging="false" NoDetailRecordsText="No additional roles assigned with this user."> <ParentTableRelation> <telerik:GridRelationFields DetailKeyField="PrimaryUserId" MasterKeyField="Id" /> </ParentTableRelation> <Columns> <telerik:GridBoundColumn DataField="Role.Title" HeaderText="Role" /> </Columns> </telerik:GridTableView> </DetailTables> <Columns> <telerik:GridTemplateColumn HeaderText=""> <HeaderStyle Width="32px" /> <ItemTemplate> <asp:Panel ID="Active" runat="server" Style="height: 16px; width: 16px;" CssClass='<%# (bool)Eval("Active") ? "active-user" : "disabled-user" %>' /> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridBoundColumn DataField="Name" HeaderText="User Name" /> <telerik:GridBoundColumn DataField="Email" HeaderText="Login" /> <telerik:GridButtonColumn ConfirmText="Are you sure you want to delete this user?" ConfirmDialogType="Classic" ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn" ImageUrl="~/Data/Skins/First/Grid/Delete.png"> <HeaderStyle Width="32px" /> <ItemStyle HorizontalAlign="Center" /> </telerik:GridButtonColumn> </Columns> </MasterTableView> <ClientSettings EnablePostBackOnRowClick="true"> <Selecting AllowRowSelect="true" /> <ClientEvents OnRowContextMenu="users_RowContextMenu" /> <Scrolling AllowScroll="True" UseStaticHeaders="True" EnableVirtualScrollPaging="True" /> </ClientSettings> </ResultGrid> <DataSource TypeName="Bfgl.First.Web.UI.UsersGridSmartSearchDataSource" DeleteMethod="Delete"> <SelectParameters> <asp:ControlParameter Name="category" ControlID="cmdUserFilterCategory" ConvertEmptyStringToNull="true" /> <asp:ControlParameter Name="roleId" ControlID="cmdUserFilterRole" ConvertEmptyStringToNull="true" /> </SelectParameters> </DataSource> <ControlsContainer> <asp:EntityDataSource ID="ds2" runat="server" ContextTypeName="Bfgl.First.Security.Data.Models.ImpersonatedSecurityEntities" EntitySetName="Users" Where="it.PrimaryUserId = @PrimaryUserId"> <WhereParameters> <asp:Parameter Name="PrimaryUserId" DbType="Guid" /> </WhereParameters> </asp:EntityDataSource> </ControlsContainer></bfo:GridSmartSearch>And here are key parts of GridSmartSearch component:
public partial class GridSmartSearch : RadWebControl, INamingContainer { private RadTextBox searchTextBox; [Browsable(false)] [PersistenceMode(PersistenceMode.InnerProperty)] public RadTextBox SearchTextBox { get { if (this.searchTextBox == null) { this.searchTextBox = new RadTextBox(); } return this.searchTextBox; } } private RadGrid resultGrid; [Browsable(false)] [PersistenceMode(PersistenceMode.InnerProperty)] public RadGrid ResultGrid { get { if (this.resultGrid == null) { this.resultGrid = new RadGrid(); } return this.resultGrid; } } private ObjectDataSource dataSource; [Browsable(false)] [PersistenceMode(PersistenceMode.InnerProperty)] public ObjectDataSource DataSource { get { if (this.dataSource == null) { this.dataSource = new ObjectDataSource(); } return this.dataSource; } } private Panel controlsContainer; [Browsable(false)] [PersistenceMode(PersistenceMode.InnerProperty)] public Panel ControlsContainer { get { if (this.controlsContainer == null) { this.controlsContainer = new Panel(); } return this.controlsContainer; } } protected override void CreateChildControls() { base.CreateChildControls(); this.Controls.Clear(); this.ConfigureView(); this.ConfigureDataSource(); if (String.IsNullOrWhiteSpace(this.ResultGrid.DataSourceID)) { this.ResultGrid.DataSourceID = this.DataSource.ID; } } protected override void OnInit(EventArgs e) { base.OnInit(e); this.EnsureChildControls(); } private void ConfigureView() { // PageLetterHiddenField this.PageLetterHiddenField.ID = "pageLetterHiddenField"; this.Controls.Add(this.PageLetterHiddenField); // SearchTextBox this.SearchTextBox.ID = "searchTextBox"; this.Controls.Add(this.SearchTextBox); if (this.GridSmartSearchType == UI.GridSmartSearchType.XmlHttpPanel) { // XmlHttpPanel this.XmlHttpPanel.ID = "xmlHttpPanel"; this.XmlHttpPanel.EnableClientScriptEvaluation = true; this.XmlHttpPanel.RenderMode = XmlHttpPanelRenderMode.Block; this.XmlHttpPanel.ServiceRequest += this.XmlHttpPanel_ServiceRequest; this.Controls.Add(this.XmlHttpPanel); } // ResultGrid this.ResultGrid.ID = "resultGrid"; if (this.ShowAlphabeticPager) { this.ResultGrid.PagerStyle.Mode = GridPagerMode.NumericPages; this.ResultGrid.PagerStyle.AlwaysVisible = true; } this.ResultGrid.ItemCreated += this.ResultGrid_ItemCreated; this.ResultGrid.ItemCommand += this.ResultGrid_ItemCommand; var ajaxLoadingPanel = (RadAjaxLoadingPanel)null; // Ajax Loading Panel if (this.ShowLoadingPanel) { ajaxLoadingPanel = new RadAjaxLoadingPanel { ID = "ajaxLoadingPanel" }; this.Controls.Add(ajaxLoadingPanel); } switch (this.GridSmartSearchType) { case UI.GridSmartSearchType.XmlHttpPanel: this.XmlHttpPanel.Controls.Add(this.ResultGrid); if (ajaxLoadingPanel != null) { this.XmlHttpPanel.LoadingPanelID = ajaxLoadingPanel.ID; } break; case UI.GridSmartSearchType.AjaxManager: this.Controls.Add(this.ResultGrid); this.Page.Load += (sender, e) => { var mgr = RadAjaxManager.GetCurrent(this.Page); if (mgr != null) { mgr.AjaxSettings.AddAjaxSetting(this.SearchTextBox, this.ResultGrid, ajaxLoadingPanel); mgr.AjaxSettings.AddAjaxSetting(this.ResultGrid, this.ResultGrid, ajaxLoadingPanel); } }; break; default: this.Controls.Add(this.ResultGrid); break; } this.Controls.Add(this.ControlsContainer); } private void ConfigureDataSource() { this.DataSource.ID = "dataSource"; if (String.IsNullOrEmpty(this.DataSource.SelectMethod)) { this.DataSource.SelectMethod = "Select"; } if (String.IsNullOrEmpty(this.DataSource.SelectCountMethod)) { this.DataSource.SelectCountMethod = "SelectCount"; } this.DataSource.EnablePaging = true; if (String.IsNullOrWhiteSpace(this.DataSource.TypeName)) { this.DataSource.TypeName = typeof(SampleGridSmartSearchDataSource).FullName; } this.DataSource.SelectParameters.Add(new Parameter("query", DbType.String) { ConvertEmptyStringToNull = true }); this.DataSource.SelectParameters.Add(new Parameter("pageLetter", DbType.String) { ConvertEmptyStringToNull = true }); this.DataSource.Selecting += this.DataSource_Selecting; this.Controls.Add(this.DataSource); } }
I attached screenshots before and after postback.
Could you help me somebody please?
Thanks
Vlad
<%@ Register TagPrefix="dnn" TagName="TextEditor" Src="~/controls/TextEditor.ascx" %><div id="divCopyContent" ><div id="divTab"> <dnn:TextEditor ID="txtNotes" runat="server" Width="700px" /></div><div class="copynote"> <input class="chkCopyNote" type="checkbox" runat="server" id="chkCopyNote" /> <asp:TextBox CssClass="customMessage" runat="server" ID="txtCustomMessage" TextMode="MultiLine" Height="100px" style="resize: none"></asp:TextBox></div></div><script type="text/javascript"> jQuery(".copynote a").click(function () { var className = jQuery(this).attr('class'); if (className.indexOf('true') != -1) {
jQuery('#%=divCopyContent.ClientID%>').find(".customMessage").val(jQuery('#%=txtNotes.ClientID%>').val()) } else { jQuery('#<%=divCopyContent.ClientID%>').find(".customMessage").val(""); } });</script><dotnetnuke> <htmlEditor defaultProvider="RadEditorProvider"> <providers> <clear /> <add name="RadEditorProvider" type="Telerik.DNN.Providers.RadEditorProvider, Telerik.DNN.Providers.RadEditorProvider" providerPath="~\Providers\RadEditorProvider" AutoCreatePaths="true" ImagesPaths="Images,*PortalRoot*" /> </providers> </htmlEditor></dotnetnuke>

