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

Current filter function

3 Answers 123 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Anzar
Top achievements
Rank 2
Anzar asked on 20 Sep 2012, 06:33 AM
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

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 Sep 2012, 07:09 AM
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.
0
Anzar
Top achievements
Rank 2
answered on 20 Sep 2012, 07:23 AM
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
0
Eyup
Telerik team
answered on 24 Sep 2012, 12:57 PM
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.
Tags
Grid
Asked by
Anzar
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Anzar
Top achievements
Rank 2
Eyup
Telerik team
Share this question
or