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

Auto Generate Columns and Column Settings

1 Answer 114 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Craig
Top achievements
Rank 1
Craig asked on 05 Jun 2011, 11:50 PM
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.
 
Thanks,
Craig

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 06 Jun 2011, 07:05 AM
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.

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

Thanks,
Princy.
Tags
Grid
Asked by
Craig
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or