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

RadGridView Custom Base Class Setting Filter Defaults

1 Answer 63 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ben
Top achievements
Rank 1
Ben asked on 15 Sep 2016, 05:17 PM

We have created our own class based on the RadGridView. It has been themed and coded so all of our grids look and operate the same throughout the application. One of our requirements is to have the filtering row available at the top row of each grid.

Through theming I have removed the filter description text and the filter selection button. What we are left with is an empty filter row across the top of the grid that users can type into to filter the grid.

The issue is that the default filtering is set to "Contains" and our requirements are for it to be set to "Starts with". Every thing I see on this board shows how to set the default filtering to the columns after they have been set. I need to set this on the Grid base or master template so all columns will have this setting. Is this possible or do I have to wait until all columns are set and the roll through them each individually?

Here is a snippet of the base class code.

// CoreRadGrid
            this.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.UseCompatibleTextRendering = false;
            this.MasterTemplate.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.None;
            this.MasterTemplate.EnableAlternatingRowColor = true;
            this.ThemeName = CoreTheme.ThemeName();
            this.RootElement.UseDefaultDisabledPaint = false;
            this.MasterTemplate.EnableFiltering = true;
   
            // set Default filter
            this.MasterTemplate.FilterDescriptors.Clear();
            FilterDescriptor filter = new FilterDescriptor();
            filter.Operator = FilterOperator.StartsWith;
            filter.IsFilterEditor = true;
            this.MasterTemplate.FilterDescriptors.Add(filter);

            this.MasterTemplate.MultiSelect = true;
            this.MasterTemplate.ViewDefinition = tableViewDefinition1;
            this.AutoGenerateColumns = true;

1 Answer, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 19 Sep 2016, 02:50 PM
Hello Ben,

Thank you for writing.

The default filter operator is set internally according to the data type of the column. The GridViewTextBoxColumn uses Contains. In order to change it to StartsWith, you would need to wait for the column to be generated.

I hope this information was useful. Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms. For more information check out this blog post and share your thoughts.
Tags
GridView
Asked by
Ben
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Share this question
or