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

Change layout depending on ReadOnly binding

1 Answer 34 Views
GridView
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 06 Apr 2011, 02:33 PM
Hi!

What I'm trying to accomplish is this:

I have a grid, that have many columns in it. When a property changes outside the grid from Open to Closed, this should affect the grid to make it ReadOnly. This is all fine, and it works great.
However, the Grid do contains a few standard GridViewDataColumns, and a few that contains a Data Template that contains a control. In the case where I use the controls, I set the control to readonly and it will be grayed out to make sure the user understands that the control is no longer usable, but the standard GridViewDataColumn won't do that for some reason. Is it somehow possible to accomplish this? See attachment if it's unclear.

telerik:RadGridView IsReadOnly="{Binding IsReadOnly}" Name="TaskGrid" ShowGroupPanel="False" ItemsSource="{Binding TaskViewModels}" SelectedItem="{Binding SelectedTask, Mode=TwoWay}" AutoGenerateColumns="False">
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn UniqueName="ProductCode" Width="150" DataMemberBinding="{Binding Task.ProductCode}" IsGroupable="False">
                    <telerik:GridViewDataColumn.Header>
                        <Grid>
                            <TextBlock Text="Delivery Item" TextWrapping="Wrap"/>
                        </Grid>
                    </telerik:GridViewDataColumn.Header>
                </telerik:GridViewDataColumn>
                               <telerik:GridViewDataColumn UniqueName="Task.Description" Header="Description" IsGroupable="False" TextWrapping="Wrap" Width="250">
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <TextBox AcceptsReturn="True" MinWidth="150" TextWrapping="Wrap" IsReadOnly="{Binding IsReadOnly}" Text="{Binding Task.Description, Mode=TwoWay}"/>
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                </telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn UniqueName="Date" DataMemberBinding="{Binding Task.Date}"  Header="Date" IsGroupable="False" DataFormatString="{} {0: yyyy-MM-dd}" />  
    </telerik:RadGridView.Columns>
</telerik:RadGridView>


public bool IsReadOnly
{
    get
    {
        if(ParentViewModel.Project != null)
            return ParentViewModel.Project.State == ProjectState.Closed;
         
        return false;
    }
}

1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 11 Apr 2011, 12:54 PM
Hi John,

If you would like to disable and make the entire GridView control to be grayed when the outside property is changed to Closed, you should set the IsEnabled  property of the GridView instead the IsReadOnly. 

In case that you would like to change the RadGridViewColumn styles individually you would find this cell style selector article helpful.

Best wishes,
Didie
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
John
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Share this question
or