RadGridView Custom Base Class Setting Filter Defaults

2 posts, 0 answers
  1. Ben
    Ben avatar
    11 posts
    Member since:
    Dec 2015

    Posted 15 Sep Link to this post

    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
                FilterDescriptor filter = new FilterDescriptor();
                filter.Operator = FilterOperator.StartsWith;
                filter.IsFilterEditor = true;

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

  2. Hristo Merdjanov
    Hristo Merdjanov avatar
    664 posts

    Posted 19 Sep Link to this post

    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.

    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.
  3. DevCraft R3 2016 release webinar banner
Back to Top