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

Styling GridViewSelectColumn in RadGridViews

1 Answer 143 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Vishal
Top achievements
Rank 1
Vishal asked on 17 Feb 2020, 01:06 PM

Greetings,

I am trying to set the GridView style.

Need to set the Grid view Row and GridViewSelectColumn disabled as per the binding value. And at the same time need red background color for disabled row.

I am trying to achieve by applying style but it is now showing the expected result.

 

              <telerik:RadGridView.RowStyle>
                    <Style TargetType="telerik:GridViewRow">
                        <Setter Property="IsEnabled" Value="{Binding IsCheckboxEnabled }"></Setter>
                        <Setter Property="Background" Value="{Binding IsCheckboxEnabled, Converter={StaticResource BoolConverter}}"></Setter>
                    </Style>
                </telerik:RadGridView.RowStyle>

where IsCheckboxEnabled  is conditional value true/false with the help of which i want row to be disabled. And Background should be red.

Converter={StaticResource BoolConverter} is used to return new SolidColorBrush(Colors.Red);

But, it is not working as expected. Showing disabled rows only for alternate rows in the grid even if IsCheckboxEnabled is property assigned as false.

Not getting proper way to disable check box and disable row with red background.

Could you please advise here.

 

Thank you.

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 20 Feb 2020, 09:18 AM

Hi Vishal,

Thank you for the provided image.

If I have understood your scenario correctly, the custom Style is applied only on the Row and not for AlternateRow. Correct me if I am wrong. In this case, you need to use the AlternateRowStyle so that the same style will be applied to alternate rows.

<telerik:RadGridView.RowStyle>
    <Style TargetType="telerik:GridViewRow">
        <Setter Property="IsEnabled" Value="{Binding IsCheckboxEnabled }"></Setter>
        <Setter Property="Background" Value="{Binding IsCheckboxEnabled, Converter={StaticResource BoolConverter}}"></Setter>
    </Style>
</telerik:RadGridView.RowStyle>
<telerik:RadGridView.AlternateRowStyle>
    <Style TargetType="telerik:GridViewRow">
        <Setter Property="IsEnabled" Value="{Binding IsCheckboxEnabled }"></Setter>
        <Setter Property="Background" Value="{Binding IsCheckboxEnabled, Converter={StaticResource BoolConverter}}"></Setter>
    </Style>
</telerik:RadGridView.AlternateRowStyle>

Give this approach a try and let me know if it works for you. If not, can you elaborate more on your scenario?

Regards,
Dinko
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Vishal
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or