C1DataGrid Disable Specific Rows

Posted by: m.bleimuth on 29 November 2018, 12:56 am EST

    • Post Options:
    • Link

    Posted 29 November 2018, 12:56 am EST

    Hi,

    how can i disable specific rows in a datagrid? The items in my itemssource have a property “CanEdit”, if this Property is set to false, i want to disable the row in the datagrid. How can i achieve this?

    I have tried following code, which should work on normal .Net datagrid but does not work with c1datagrid:

     <Style TargetType="c1:DataGridRowPresenter">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding Path=CanSave}" Value="False">
                                <Setter Property="IsEnabled" Value="False"/>
                                <Setter Property="Background" Value="LightGray"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
    
    

    Thanks

  • Posted 2 December 2018, 5:18 pm EST

    Hello Manuel,

    C1.WPF.DataGrid.DataGridRow does not has a setter for IsEditable property.

    As a workaround, I suggest you to handle the BeginningRowEdit event of C1DataGrid to make it a readonly cell.

    Here is the suggested code:

    private void _grid_BeginningRowEdit(object sender, C1.WPF.DataGrid.DataGridEditingRowEventArgs e)
    {
        if(!(e.Row.DataItem as Employee).IsPresent)
        {
            e.Cancel = true;
        }
    }
    
    

    Please find attached demo sample.

    Thanks,

    Ruchir

    ReadOnlyRow_DataGrid.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels