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

Template Autogenerating Columns

3 Answers 121 Views
GridView
This is a migrated thread and some comments may be shown as answers.
AdaDog
Top achievements
Rank 1
AdaDog asked on 19 Oct 2011, 10:36 PM
Does anyone have a behavior or attached property that would enabled me to create GridViewDataColumn "templates" for all of the possible columns that are autogenerated from DataTable?  The ItemsSource is a DataTable that could have various different columns from a finite list of all potential columns.  I'd like to template every potential column.

3 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 20 Oct 2011, 04:10 PM
Hello Doug Simpson,

The DataType of the column in a datatable may  be any .NET type. And v.4  of the .NET framework has above 6000 types (classes) defined.

I believe I may be getting the question wrong , otherwise we may need 6000+ template versions here ?


Best wishes,
Pavel Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Pavel Pavlov
Telerik team
answered on 20 Oct 2011, 04:24 PM


Generally, to achieve a match between template and DataType when autogenerating columns , the approach would be as follows :

1. Define your template in a static resource .
2. Handle the AutogeneratingColumnEvent of RadGridView.
3. Inside the event handler - check the DataType  and set the  template to the column , reading it from the static resource.


In case you have difficulties implementing this , let me know .

Best wishes,
Pavel Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
AdaDog
Top achievements
Rank 1
answered on 20 Oct 2011, 04:26 PM
I guess I worded my question poorly.  Let me try again.
I have 20 columns that make up a "master" DataTable.  The gridview is bound to a copy of this DataTable with some columns.  Not necessarily all the columns in the master are in the copy.  All columns in the copy are in the master.  The columns shown in the copy are dynamic.  Columns can be removed and added to and from the copy, but all of the columns are in the master.  (Note: column visibility is an additional feature on the copy DataTable beyond selecting a subset of columns from the master).  I'd like to template (in XAML) each of the columns in the master but have them applied to the copy to which the gridview is bound.
Tags
GridView
Asked by
AdaDog
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
AdaDog
Top achievements
Rank 1
Share this question
or