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

Hiding Columns when using MVVM

6 Answers 154 Views
GridView
This is a migrated thread and some comments may be shown as answers.
JAS J
Top achievements
Rank 1
JAS J asked on 07 Jul 2011, 11:54 PM
Hi, I am binding my RadGridView to an ObservableCollection<>. However, I do not want all columns to show up in my Grid View. Is there a way to hide it in XAML or as some annotation in the class definition?

I could make the undesired fields private and it disappears, but there are some times when I use the another ObservableCollection of the same object where I want all the columns
thanks
jcb

6 Answers, 1 is accepted

Sort by
0
bhavik
Top achievements
Rank 1
answered on 22 Jul 2011, 04:29 AM
I am also facing similar issue :(
0
Maya
Telerik team
answered on 22 Jul 2011, 07:17 AM
Hello Bhavik,

You may try to set the IsVisible property of the column to "False".
 

Regards,
Maya
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
bhavik
Top achievements
Rank 1
answered on 10 Jan 2012, 10:21 AM
Thanks that worked!

I am hiding the column from the view model at start. Based on some drop down changes, i want to show the column.
But I when I associate this property using two way binding property, its not getting updated to unhide the column.
0
Maya
Telerik team
answered on 10 Jan 2012, 10:41 AM
Hello,

Could you share a bit more details about your implementation? Generally, any relevant information and code-snippet would be helpful. 


Greetings,
Maya
the Telerik team

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

0
bhavik
Top achievements
Rank 1
answered on 10 Jan 2012, 03:28 PM
Thanks Maya for your reply.

Here's my sample code

<telerik:GridViewDataColumn Width="150"  DataMemberBinding="{Binding Status}" IsVisible= "{Binding Source={StaticResource MyViewModel}, Path=IsAdminUser}">

   <telerik:GridViewDataColumn.Header>

      <TextBlock Text="Status"/>

   </telerik:GridViewDataColumn.Header>

</telerik:GridViewDataColumn>

View Model: MyViewModel

 

 public bool IsAdminUser
 {
    get { return isAdminUser; }
    set 
    {
       isAdminUser = value;
       RaisePropertyChanged(() => this.IsAdminUser);
    }
 }
0
Maya
Telerik team
answered on 10 Jan 2012, 03:40 PM
Hello,

I believe this forum thread might be helpful in your case. Please take a look at it and let me know in case you have any further difficulties.
 

Kind regards,
Maya
the Telerik team

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

Tags
GridView
Asked by
JAS J
Top achievements
Rank 1
Answers by
bhavik
Top achievements
Rank 1
Maya
Telerik team
Share this question
or