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

mvvm binding, columns visibility and columnheaders

3 Answers 88 Views
GridView
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 20 Jun 2012, 09:14 AM
Hi, I have two question I can't find in the forum:

1-. I have a RadGridView binded to datasource, once the data is binded (or binding), how can i tell RadGridView wich columns are visibles and which aren't. (AutogenerateCoumns=true)

2-. Is there a way to bind columnheaders?

We are using MVVM pattern

Thanks

3 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 20 Jun 2012, 10:33 AM
Hi,

Please find my recommendations to your questions:
1. You could inspect the IsVisible property of the GridView columns.
2. The column header is of type object, so you are not limited to just using plain text. 
You could bind the header like so:

<telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" Header="{Binding MyHeaderName, Source={StaticResource MyViewModel}}"/>

I hope this helps.

Regards,
Didie
the Telerik team

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

0
David
Top achievements
Rank 1
answered on 20 Jun 2012, 10:43 AM
The grid has AutogenerateColumns=true;

1-. The only way is having one property for the IsVisible property for each column? Anyway, with autogenerateColumns=true how could I bind the IsVisbile property?

2-. Alike, IsVisible property, how could I bind the headercolumn with autogeneratecolumn=true? I need this behaviour to change the header text for localization.

Thanks
0
Dimitrina
Telerik team
answered on 21 Jun 2012, 10:25 AM
Hello,

 You could subscribe for the AutoGeneratingColumn event of the RadGridView and set the binding with a code similar to this one:

Binding binding = new Binding();
b.Source = "your source";
b.Path = "path";
column.IsVisible = binding;

The same applies for the binding of the column headers.

Kind regards,
Didie
the Telerik team

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

Tags
GridView
Asked by
David
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
David
Top achievements
Rank 1
Share this question
or