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

RadGridView set ReadOnly or Enabled on a column based on a checkbox

1 Answer 769 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Andy
Top achievements
Rank 1
Andy asked on 22 Jul 2013, 01:33 PM
I have a RadGridView and in this RadGridView I have the following column:

<telerik:GridViewCheckBoxColumn DataMemberBinding="{Binding Revoked}" AutoSelectOnEdit="True" Header="Revoked" UniqueName="Revoked" Width="Auto" IsReadOnly="False" FooterTextAlignment="Right" CellStyle="{StaticResource GridCellStyle}" />


I want to either enable/disable or set the read only flag on another two columns in the grid based on the checkbox column.

 
<telerik:GridViewDataColumn
     DataMemberBinding="{Binding RevokedBy}"
     Header="Revoked By"
     UniqueName="RevokedBy"
     Width="Auto"
     IsReadOnly="{Binding Revoked}"
     FooterTextAlignment="Right"
     CellStyle="{StaticResource GridCellStyle}" />
 
 <telerik:GridViewDataColumn
     DataMemberBinding="{Binding RevokedDateTime}"
     DataFormatString="dd/MM/yyyy HH:mm:ss"
     Header="Revoked Date Time"
     UniqueName="RevokedDateTime"
     Width="Auto"
     IsReadOnly="{Binding Revoked}"
     FooterTextAlignment="Right"
     CellStyle="{StaticResource GridCellStyle}">
    <telerik:GridViewDataColumn.CellEditTemplate>
        <DataTemplate>
            <WrapPanel Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="4">
                <telerik:RadDateTimePicker
                    Margin="0 5 5 5"
                    Width="250"
                    DisplayFormat="Short"                                    
                    InputMode="DatePicker"
                    DateSelectionMode="Day"
                    DateTimeWatermarkContent="Select Date"
                    MaxWidth="155"
                    MinWidth="155"
                    SelectedDate="{Binding RevokedDate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
  
                <telerik:RadMaskedDateTimeInput
                    Margin="5"
                    Culture="en-GB"
                    EmptyContent="Enter Time"
                    InputBehavior="Replace"
                    Mask="HH:mm:ss"
                    SelectionOnFocus="SelectAll"
                    TextMode="MaskedText"
                    Value="{Binding RevokedTime, Mode=TwoWay}"/>
            </WrapPanel>
        </DataTemplate>
    </telerik:GridViewDataColumn.CellEditTemplate>
 </telerik:GridViewDataColumn>


So far I have tried binding the `IsReadOnly` and `IsEnabled` property to `Revoked` but this doesn't seem to work, and I can see that the `Revoked` property is being set and the `RaisePropertyChanged` event is recurring.

Any help would be much appreciated.

Further details of the code in the ViewModel

/// <summary>
/// The agreements.
/// </summary>
private ObservableCollection<NotificationAgreement> agreements;
 
/// <summary>
/// Gets or sets the agreements.
/// </summary>
public ObservableCollection<NotificationAgreement> Agreements
{
    get
    {
        return this.agreements ?? (this.agreements = new ObservableCollection<NotificationAgreement>());
    }
 
    set
    {
        this.agreements = value;
        this.RaisePropertyChanged(() => this.Agreements);
    }
}



And the NotificationAgreement class has the following property.

/// <summary>
/// Gets or sets a value indicating whether revoked.
/// </summary>
public bool Revoked
{
    get
    {
        return this.revoked;
    }
 
    set
    {
        this.revoked = value;
        this.RaisePropertyChanged(() => this.Revoked);
    }
}



1 Answer, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 23 Jul 2013, 12:59 PM
Hi Andy,

I can suggest you to check this help article which shows how to control which rows or cells to be read only.

Regards,
Yoan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
Andy
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Share this question
or