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

Filters on dynamic colmum

2 Answers 144 Views
GridView
This is a migrated thread and some comments may be shown as answers.
JC
Top achievements
Rank 1
JC asked on 11 Mar 2020, 02:31 PM

Hello

I have a Grid with dynamic object on DataSource with AutoGeneratedColumns.

When I open a filter on any column, i only have 4 options : "equals / not equals / null / not null"

How can I activate "contains" when my colum is string ?

To reproduce, you can test on 'BindingToDynamicObject' project on sdk (https://github.com/telerik/xaml-sdk/tree/master/GridView/BindingToDynamicObject)

Thanks for your help

2 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 16 Mar 2020, 02:25 PM

Hello JC,

The operators available for each column are generated  based on its data type. The filtering treats the dynamic fields (like in the BindingToDynamicObject SDK example) as  System.Object elements. The System.Object data type support only 4 operators - for equality and for null values. To change this, you can explicitly set the DataType property of the columns. For automatically created columns, you can do that with the AutoGeneratingColumn event.

private void RadGridView_AutoGeneratingColumn(object sender, Telerik.Windows.Controls.GridViewAutoGeneratingColumnEventArgs e)
{
	var column = (GridViewDataColumn)e.Column;
      // based on the current column, set the DataType property
	column.DataType = typeof(string);
}

Regards,
Martin Ivanov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
JC
Top achievements
Rank 1
answered on 17 Mar 2020, 02:13 PM
Thanks a lot, it works fine
Tags
GridView
Asked by
JC
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
JC
Top achievements
Rank 1
Share this question
or