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

Programmically creating filter with RadGridView

1 Answer 368 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Michael Bouhuys
Top achievements
Rank 1
Michael Bouhuys asked on 22 Jun 2018, 02:47 PM

Have a RadGridView set up with AutoGenerateColumns="True". The grid is populated by:

    SqlDataAdapter dataAdapter = new SqlDataAdapter();
                dataAdapter.SelectCommand = _sqlCommand;
                DataTable dataTable = new DataTable();
                dataAdapter.Fill(dataTable);
                MRSuserSource = dataTable;

All is well at this point the end-user can use the data filter of the grid to sort on whatever column and whatever data. Using AutoGenerateColumns because based on SQL database the number of columns will be more or less.

Looking to create specific filters.

Using some samples and documentation running into a problem on how to do the "column programmatically" as seen in this document "https://docs.telerik.com/devtools/wpf/controls/radgridview/filtering/programmatic#filtering-single-column".

The question becomes how is to define the filter when the columns are automatically created and getting the DataTable to be seen as "GridViewColumn". Maybe missing other details that are being overlooked.

1 Answer, 1 is accepted

Sort by
0
Vladimir Stoyanov
Telerik team
answered on 27 Jun 2018, 11:47 AM
Hello Michael,

May I ask you some questions in order to better assist you? Can you specify what problems you have encountered while attempting to filter a column programmatically? In general even though the columns are auto generated, you should be able to apply the approach described in the Programmatic Filtering article that you referenced. Moreover may I ask you to specify what you mean by "getting the DataTable to be seen as "GridViewColumn""? Please note that even though the RadGridView is bound to a datatable, it will create gridviewcolumns and you should be able to filter them as suggested in the article above. 

That said if you still have any problems may I ask you to explain in more detail what you are trying to achieve? You can also open a new support ticket and attach a sample project demonstrating the exact scenario.

Regards,
Vladimir Stoyanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
GridView
Asked by
Michael Bouhuys
Top achievements
Rank 1
Answers by
Vladimir Stoyanov
Telerik team
Share this question
or