Current filter function

4 posts, 0 answers
  1. Anzar
    Anzar avatar
    62 posts
    Member since:
    Sep 2012

    Posted 20 Sep 2012 Link to this post

    Hi,

    I have to set current filter function at run time and when i click on the filter button it take the currently setted filter function.

    Thanks & Regards
    Anzar.M
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 20 Sep 2012 Link to this post

    Hi,

    You can set the CurrentFilterFunction in Prerender event as shown below.
    C#:
    protected void RadGrid1_PreRender(object sender, EventArgs e)
    {
     foreach (GridColumn column in RadGrid1.MasterTableView.Columns)
     {
       if (column.UniqueName == "UniqueName")
       {
          column.CurrentFilterFunction = GridKnownFunction.Between;
       }
     
    }

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Anzar
    Anzar avatar
    62 posts
    Member since:
    Sep 2012

    Posted 20 Sep 2012 Link to this post

    Hi shinu ,

    My code is below.

      protected void rgDocumentType_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
     {
       TextBox tbFilter=null;
                    AjaxControlToolkit.FilteredTextBoxExtender ftExtender;
                    if (e.Item is GridFilteringItem)
                    {
                        GridFilteringItem fItem = (GridFilteringItem)e.Item;
                        foreach (GridColumn col in rgDocumentType.MasterTableView.Columns)
                        {
                            
                        
                            if (Convert.ToString(col.UniqueName).Equals("colIsModified") == false && Convert.ToString(col.UniqueName).Equals("colActive") == false && Convert.ToString(col.UniqueName).Equals("colCONCUR_ID") == false && Convert.ToString(col.UniqueName).Equals("colRemark") == false)
                            {
                                
                                  tbFilter  = fItem[col.UniqueName].Controls[0] as TextBox;
                                  tbFilter.ID = col.UniqueName;
                                  ftExtender = new AjaxControlToolkit.FilteredTextBoxExtender();
                                   ftExtender.TargetControlID = tbFilter.ID;
                                   ftExtender.FilterMode = AjaxControlToolkit.FilterModes.InvalidChars;
                                   ftExtender.FilterType=AjaxControlToolkit.FilterTypes.Custom|AjaxControlToolkit.FilterTypes.Numbers|AjaxControlToolkit.FilterTypes.LowercaseLetters | AjaxControlToolkit.FilterTypes.UppercaseLetters;
                                   ftExtender.InvalidChars = @"%!&;`'\|*?~<>^()[]{}$&quot;";
                                   tbFilter.Controls.Add(ftExtender);

                                   col.CurrentFilterFunction = GridKnownFunction.Contains;
                                   col.AutoPostBackOnFilter = true;

                                  
                                  
                                   ftExtender = null;
                                   tbFilter = null;
                                

                                                          
                            }
                           
                        }
                    } 


    }


    I set the current filter function here But when clicking on the filter menu button it does not work?

    Thanks & Regards
    Anzar.M
  5. Eyup
    Admin
    Eyup avatar
    3007 posts

    Posted 24 Sep 2012 Link to this post

    Hi Anzar,

    I am afraid it is not a good idea to traverse through the Grid columns on ItemCreated event. Could you please elaborate some more on your specific requirement? What exactly do you want to achieve and whether the approach suggested by Shinu works for you?

    Regards,
    Eyup
    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.
Back to Top