We have a similar page to the demo grid here: http://demos.telerik.com/aspnet-ajax/grid/examples/programming/filteringtemplatecolumns/defaultcs.aspx In many of the columns, we have RadComboBoxes similar to the "Custom TemplateColumn Country" column.
Issue occurring / High Level:
If I move one of the columns, no postbacks occur. If I then use one of these RadComboBoxes to filter, then a postback occurs and all of the values in the drop downs (filled on prerender) are cleared out. If I then filter again (causing a postback) the values reappear. I'm not handling a certain event. Any ideas out there? Once you see the steps, it should seem obvious, but I'm not seeing it.
Any help would be great!
Steps to Reproduce:
ASPX.CS
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
RadGridApples.DataSource = [datasource];
RadGridApples.DataBind();
}
}
public void GetNewResults(object sender, EventArgs e)
{
//Update the datasource code
RadGridApples.DataSource = [enter datasource here];
RadGridApples.DataBind();
}
protected void RadGridApples_PreRender(object sender, EventArgs e)
{
foreach (GridFilteringItem filter in RadGridApples.MasterTableView.GetItems(GridItemType.FilteringItem))
{
#region Drop Down
radComboBoxApples = (RadComboBox)filter.FindControl("radComboBoxApples");
if (radComboBoxApples != null)
{
radComboBoxApples.ClearSelection();
radComboBoxApples.DataSource = Enum.GetNames(typeof(Apples)).ToList();
radComboBoxApples.DataBind();
}
ASPX
Grid information:
<telerik:RadGrid ID="RadGridApples" runat="server" AllowFilteringByColumn="True"
AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"
GridLines="None" onprerender="RadGridApples_PreRender" Width="100%"
PageSize="5" OnPageIndexChanged="RadGridApples_PageIndexChanged"
OnSortCommand="GetNewResults" OnPageSizeChanged="GetNewResults" Skin="Outlook"
>
Example column:
<telerik:GridBoundColumn HeaderText="Apples" UniqueName="appleCombo"
DataField="Apple"
SortAscImageUrl="\App_Themes\XYZ\img\RadGrid\SortAsc.gif"
SortDescImageUrl="\App_Themes\XYZimg\RadGrid\SortDesc.gif"
SortExpression="Apple"
>
<HeaderStyle Width="90px" />
<ItemStyle HorizontalAlign="Left" Width="90px"></ItemStyle>
<FilterTemplate>
<telerik:RadComboBox ID="RadComboBoxApples" runat="server" AutoPostBack="True" AppendDataBoundItems="true" Width="100%" OnSelectedIndexChanged="GetNewResults">
<Items>
<telerik:RadComboBoxItem Text="" Value="" />
</Items>
</telerik:RadComboBox>
</FilterTemplate>
</telerik:GridBoundColumn>
Client Settings in the grid:
<ClientSettings AllowColumnsReorder="True"
AllowRowHide="True" AllowRowsDragDrop="True" ReorderColumnsOnClient="True">
<Selecting AllowRowSelect="True" />
<Scrolling AllowScroll="True" UseStaticHeaders="True" />
<Resizing AllowColumnResize="True" ClipCellContentOnResize="False" />
</ClientSettings>
Issue occurring / High Level:
If I move one of the columns, no postbacks occur. If I then use one of these RadComboBoxes to filter, then a postback occurs and all of the values in the drop downs (filled on prerender) are cleared out. If I then filter again (causing a postback) the values reappear. I'm not handling a certain event. Any ideas out there? Once you see the steps, it should seem obvious, but I'm not seeing it.
Any help would be great!
Steps to Reproduce:
- Load grid: Grid is not automatically created. I create the datasource and databind, then use the radgrid prerender to fill the drop down values in the gridboundcolumn filtertemplates.
- Use the mouse to move one of the columns to a new location.
- Use a column's filter (RadComboBox) to filter an item in the grid. (Postback occurs, calls special function on the server which again sets the datasource and rebind, then runs the radGrids prerender.
- Go and open one of the drop downs filled on the prerender and they're empty.
- If I change a filter somewhere else that causes a postback, the RadComboBoxes are refilled
ASPX.CS
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
RadGridApples.DataSource = [datasource];
RadGridApples.DataBind();
}
}
public void GetNewResults(object sender, EventArgs e)
{
//Update the datasource code
RadGridApples.DataSource = [enter datasource here];
RadGridApples.DataBind();
}
protected void RadGridApples_PreRender(object sender, EventArgs e)
{
foreach (GridFilteringItem filter in RadGridApples.MasterTableView.GetItems(GridItemType.FilteringItem))
{
#region Drop Down
radComboBoxApples = (RadComboBox)filter.FindControl("radComboBoxApples");
if (radComboBoxApples != null)
{
radComboBoxApples.ClearSelection();
radComboBoxApples.DataSource = Enum.GetNames(typeof(Apples)).ToList();
radComboBoxApples.DataBind();
}
ASPX
Grid information:
<telerik:RadGrid ID="RadGridApples" runat="server" AllowFilteringByColumn="True"
AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"
GridLines="None" onprerender="RadGridApples_PreRender" Width="100%"
PageSize="5" OnPageIndexChanged="RadGridApples_PageIndexChanged"
OnSortCommand="GetNewResults" OnPageSizeChanged="GetNewResults" Skin="Outlook"
>
Example column:
<telerik:GridBoundColumn HeaderText="Apples" UniqueName="appleCombo"
DataField="Apple"
SortAscImageUrl="\App_Themes\XYZ\img\RadGrid\SortAsc.gif"
SortDescImageUrl="\App_Themes\XYZimg\RadGrid\SortDesc.gif"
SortExpression="Apple"
>
<HeaderStyle Width="90px" />
<ItemStyle HorizontalAlign="Left" Width="90px"></ItemStyle>
<FilterTemplate>
<telerik:RadComboBox ID="RadComboBoxApples" runat="server" AutoPostBack="True" AppendDataBoundItems="true" Width="100%" OnSelectedIndexChanged="GetNewResults">
<Items>
<telerik:RadComboBoxItem Text="" Value="" />
</Items>
</telerik:RadComboBox>
</FilterTemplate>
</telerik:GridBoundColumn>
Client Settings in the grid:
<ClientSettings AllowColumnsReorder="True"
AllowRowHide="True" AllowRowsDragDrop="True" ReorderColumnsOnClient="True">
<Selecting AllowRowSelect="True" />
<Scrolling AllowScroll="True" UseStaticHeaders="True" />
<Resizing AllowColumnResize="True" ClipCellContentOnResize="False" />
</ClientSettings>