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

Change textbox filter by RadComboBox

6 Answers 197 Views
Filter
This is a migrated thread and some comments may be shown as answers.
Andy
Top achievements
Rank 1
Andy asked on 29 Sep 2010, 10:27 PM
Hi all!

I'm adding the filter for my RadGrid by set AllowFilteringByColumn="True"
However, it uses the textbox which is not good so much in some cases.
I see the RadComboBox allows user to search data by using its own Filter. So I would like to apply RadComboBox into the FIlter
Is there any ways to replace the textbox by RadComboBox ?

Thanks!

Andy.

6 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 30 Sep 2010, 08:21 AM
Hello Andy,

In Telerik RadGrid you can enable dropdown filters for GridBoundColumns (or those columns which inherit from GridBoundColumns like GridDateTimeColumn, GridNumericColumn, etc.) and GridTemplateColumns declaratively - just set AllowFilteringByColumn = true for the entire grid and define FilterTemplate for the columns in question. Review the links below for more information:
Filter templates
Filter templates - help topic

I hope this helps.

All the best,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Andy
Top achievements
Rank 1
answered on 30 Sep 2010, 03:11 PM
Thanks Pavlina!

I try to do it now

Andy.
0
asilioni
Top achievements
Rank 1
answered on 09 Mar 2012, 08:23 AM
Hi,
I am using a radcombobox for filtering radgrid. The filter works fine but after the selection of the radcombobox, it looses the selected value.  Each radcombobox item, contains an image and a title, that's why i fill in the radcombobox in the ItemDataBound event (so i can set the Item.Image value).  This is probably happens because in the ItemDataBound event the radcombobox is populated again with the values. How can i keep the selected value?

Thanks a lot,
Angie
<FilterTemplate>
  
                                <telerik:RadComboBox runat="server"
  
                                 ID="cboIcon"
  
                                 DataTextField="ConsultStatus"
  
                                 Text='<% Eval("ConsultStatus")%>'
 
                                 DataValueField="ConsultStatus"
 
                                 OnClientSelectedIndexChanged="IconIndexChanged"
  
                                 OnSelectedIndexChanged="cboIcon_SelectedIndexChanged">                            
 
                                </telerik:RadComboBox>
  
                                  
  
                                <telerik:RadScriptBlock ID="RadScriptBlock2" runat="server">
  
  
  
                                <script type="text/javascript">
  
                                    function IconIndexChanged(sender,args) {
  
                                        var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
  
                                        var filterVal = args.get_item().get_value();                                                                                  
 
                                              
  
                                        if (filterVal == "0") {
  
                                            tableView.filter("ConsultStatus", "Σε εξέλιξη", "EqualTo");
  
                                        }
  
                                        else if (filterVal == "1") {
  
                                            tableView.filter("ConsultStatus", "Υπό έγκριση", "EqualTo");
  
                                        }
  
                                        else if (filterVal == "2") {
  
                                            tableView.filter("ConsultStatus", "Προς δημιουργία εγκυκλίου", "EqualTo");
  
                                        }
  
                                        else if (filterVal == "3") {
  
                                            tableView.filter("ConsultStatus", "Κλειστές", "EqualTo");
  
                                        }
  
                                        else if (filterVal == "4") {
  
                                            tableView.filter("ConsultStatus", "Ακυρωμένες", "EqualTo");
  
                                        }
  
                                         
  
                                    }
  
                                </script>
  
  
  
                            </telerik:RadScriptBlock>
  
  
  
                                </

0
Pavlina
Telerik team
answered on 11 Mar 2012, 11:55 PM
Hello,

You can store the combo box selected value in session/ViewState, and in the PreRender event handler for the grid, get a reference to it, and restore its value.

All the best,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
asilioni
Top achievements
Rank 1
answered on 12 Mar 2012, 02:42 PM
Hi Pavlina,
after testing your suggestion again and again I get the following error from the web page ang the filters do not work at all.. The error is the following:

Sys.WebForms.PageRequestManagerServerErrorException: an item with the same key has already been added

Could you please help me? I'm sending you the code that i have added.

Thanks a lot,
Angie
/// <summary>
        /// When selected consultation type in radcombobox changes, we need to store the selected value to a session
        /// and set it as selected in the OnPreRender event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void cboType_SelectedIndexChanged(object sender, EventArgs e)
        {
            RadComboBox cbo = (RadComboBox)sender;
            Session["cboTypeSelectedValue"] = cbo.SelectedValue;                       
        }
 
        /// <summary>
        /// Set the value stored in session as the selected value of the radcombobox
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void cboType_PreRender(object sender, EventArgs e)
        {
            RadComboBox cbo = (RadComboBox)sender;
 
            if (Session["cboTypeSelectedValue"] != null)
                cbo.SelectedValue = Session["cboTypeSelectedValue"].ToString();                           
        }

0
asilioni
Top achievements
Rank 1
answered on 15 Mar 2012, 10:41 AM
Hi Pavlina,
finally I solved my problem!! The reason for the exception was that my page was not approved!!

Thanks anyway!
Tags
Filter
Asked by
Andy
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Andy
Top achievements
Rank 1
asilioni
Top achievements
Rank 1
Share this question
or