Change textbox filter by RadComboBox

7 posts, 0 answers
  1. Andy
    Andy avatar
    107 posts
    Member since:
    Sep 2010

    Posted 29 Sep 2010 Link to this post

    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.
  2. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 30 Sep 2010 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Andy
    Andy avatar
    107 posts
    Member since:
    Sep 2010

    Posted 30 Sep 2010 Link to this post

    Thanks Pavlina!

    I try to do it now

    Andy.
  5. asilioni
    asilioni avatar
    17 posts
    Member since:
    Feb 2011

    Posted 09 Mar 2012 Link to this post

    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>
      
      
      
                                    </

  6. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 11 Mar 2012 Link to this post

    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.
  7. asilioni
    asilioni avatar
    17 posts
    Member since:
    Feb 2011

    Posted 12 Mar 2012 Link to this post

    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();                           
            }

  8. asilioni
    asilioni avatar
    17 posts
    Member since:
    Feb 2011

    Posted 15 Mar 2012 Link to this post

    Hi Pavlina,
    finally I solved my problem!! The reason for the exception was that my page was not approved!!

    Thanks anyway!
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017