Auto Generate Columns and Column Settings

2 posts, 0 answers
  1. Craig
    Craig avatar
    20 posts
    Member since:
    Aug 2006

    Posted 05 Jun 2011 Link to this post

    I have a grid bound to a dynamic view. I am using the NeedDataSource and have the AutoGenerateColumns set to true because I never know what the column headers or count will be.

    I have AllowFiltering set to true to allow users to work with the returned data. There are a couple of column settings I would like to apply to all columns and I am hoping to avoid writing a bunch of code in the PreRender event and then rebinding.

    I would like to set the default filter (CurrentFilterFunction) to "StartsWith" and not "Contains" for all columns.
    I would like to set the default FilterControlWidth to be the same width for all columns. I noticed that string columns are one size and numeric columns are another (larger?).

    I've serched through the forums but can't find anything. If someone can provide a link or a suggestion that would be great.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 06 Jun 2011 Link to this post

    Hello Craig,

    In order to set FilterControlWidth and replace default filter as "StartsWith", attach ColumnCreated event to your RadGrid and then replace the default filter function and set FilterControlWidth as shown below.

    protected void RadGrid2_ColumnCreated(object sender, GridColumnCreatedEventArgs e)
           foreach (GridColumn column in RadGrid2.Columns)
             column.FilterControlWidth = Unit.Pixel(70);
             column.CurrentFilterFunction = GridKnownFunction.StartsWith;

  3. DevCraft R3 2016 release webinar banner
Back to Top