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

FilterTemplate + RadCombox, help!

0 Answers 58 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tomasz
Top achievements
Rank 1
Tomasz asked on 08 Apr 2011, 09:21 AM

Hello.
I have a radgrid with gridtemplate column in it. In gridtemplate column i have placed filtertemplate with radcombox. I'm populating the grid with OnNeedDataSource method. Te code sample looks like this

<telerik:GridTemplateColumn DataField="Obraz" Visible="false" Resizable="false" UniqueName="TemplateColumn"   AllowFiltering="true">
<FilterTemplate>
 <telerik:RadComboBox ID="ComboFilterBox" runat="server" AppendDataBoundItems="true" OnSelectedIndexChanged="FilterCombo_SelectedIndexChanged" DataTextField="Text" DataValueField="Obraz" AutoPostBack="true">
  <items>
  <telerik:RadComboBoxItem Text="Bez filtra" value="1"/>
  <telerik:RadComboBoxItem Text="value1" value="~Gif/pic1.png"/>
  <telerik:RadComboBoxItem Text="value2" value="~/Gif/pic2.png"/>
  <telerik:RadComboBoxItem Text="value3" value="~/Gif/pic3.png"/>
  <telerik:RadComboBoxItem Text="value4" value=""/>
   </items>
   </telerik:RadComboBox>
   </FilterTemplate>
  <ItemTemplate>
  <asp:Image ID="Image1" runat="server" ImageUrl="<%# bind('Obraz') %>" ForeColor="White" />
  </ItemTemplate>
  <HeaderStyle Width="199px" />
   <ItemStyle Width="199px" />
   </telerik:GridTemplateColumn>

and then in server code i have

protected void FilterCombo_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
        {
  
            Session["selectedComboitem"] = e.Text;
  
            string filterExpression;
            if (e.Value != "")
            {
                filterExpression = "([Obraz] = '" + e.Value + "')";
            }
            else
            {
                filterExpression = "";
            }
            RadGrid1.MasterTableView.FilterExpression = filterExpression;
            RadGrid1.MasterTableView.Rebind();
        }

and the filtering is ok, but every time i change the radcombox item after the grid is filtered the combox looks like it is rebinded and it allways show as the selected item is the first item of ComboBox, the filter results are ok, but I realy need to remember the selected item, i have readed many post's and try to filter with client-side (http://www.telerik.com/help/aspnet-ajax/grid-filtertemplate.html) but it does not work for me. Can any one help me please?  

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Tomasz
Top achievements
Rank 1
Share this question
or