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

RadGridView row color if the checkbox is checked

8 Answers 322 Views
GridView
This is a migrated thread and some comments may be shown as answers.
pv Upendran
Top achievements
Rank 1
pv Upendran asked on 10 Sep 2009, 11:10 AM
i want to change the background color of the particular row in Radgridview, if the checkbox  is checked=true.can u anybody help me.
i will be waiting for ur reply

8 Answers, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 10 Sep 2009, 11:19 AM
Hello pv Upendran,

Where is the CheckBox placed? Is it in a particular cell of a row?Or is it outside RadGridView?

All the best,
Milan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
pv Upendran
Top achievements
Rank 1
answered on 11 Sep 2009, 05:32 AM
Hi,
 Thanks for your prompt reply. I'm using CellTemplate to add the CheckBox I'll show u the Sample code of XAML

        <telerikGrid:RadGridView x:Name="rgvTripHistory" IsFilteringAllowed="False" MultipleSelect="True" AutoGenerateColumns="False" Width="Auto" Height="Auto" FontFamily="Verdana" FontSize="14" ShowGroupPanel="false"
                                 UseAlternateRowStyle="True"  Canvas.Left="8" VerticalAlignment="Top" Canvas.Top="312" 
                                 Style="{StaticResource RadGridViewStyle1}" RowStyle="{StaticResource GridViewRowStyle1}"
                                 Background="{StaticResource GridViewRowBackground}" AlternateRowStyle="{StaticResource GridViewRowStyle2}"    RowLoaded="rgvTripHistory_RowLoaded" >
            <telerikGrid:RadGridView.Columns>

                <!--<telerikGrid:GridViewDataColumn x:Name="gvCheckBoxColumn" IsReadOnly="False" HeaderCellStyle="{StaticResource GridViewHeaderCellStyle1}" UniqueName="Dispute" HeaderText="Dispute" Width="70" />-->

                <telerikGrid:GridViewDataColumn  HeaderCellStyle="{StaticResource GridViewHeaderCellStyle1}" HeaderText="Dispute" Width="70">
                    <telerikGrid:GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox x:Name="chkDispute" IsChecked="{Binding Dispute}" Tag="{Binding CustomerTripID}" Click="chkDispute_Checked"  HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </DataTemplate>
                    </telerikGrid:GridViewColumn.CellTemplate>
                </telerikGrid:GridViewDataColumn>

                <telerikGrid:GridViewDataColumn IsReadOnly="True" HeaderCellStyle="{StaticResource GridViewHeaderCellStyle1}" UniqueName="CustomerTripID" HeaderText="Trip ID" />
                <telerikGrid:GridViewDataColumn IsReadOnly="True" HeaderCellStyle="{StaticResource GridViewHeaderCellStyle1}" UniqueName="ExitLocID" HeaderText="Location" />
            </telerikGrid:RadGridView.Columns>
        </telerikGrid:RadGridView>

Pls give me the solution. As soon as possible.
0
Milan
Telerik team
answered on 16 Sep 2009, 09:46 AM
Hi pv Upendran,

You just have to find the parent row in the chkDispute_Checked event handler and change the Background property. Here is a sample code:

Brush originalBackgound;  
 
private void chkDispute_Checked(object sender, RoutedEventArgs e)  
{  
    var element = sender as CheckBox;  
    var parentRow = element.ParentOfType<GridViewRow>();  
 
    if (originalBackgound == null)  
        this.originalBackgound = parentRow.Background;  
 
    if (element.IsChecked.HasValue && element.IsChecked.Value)  
        parentRow.Background = new SolidColorBrush(Colors.Cyan);  
    else 
        parentRow.Background = originalBackgound;  

The code will also revert to the original color when you uncheck the CheckBox.

Kind regards,
Milan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
V
Top achievements
Rank 1
answered on 27 Jan 2011, 01:16 AM
Hi,
I am student and new user of Telerik controls. I am using Silverlight RadGridView Control. My Checkboxes are placed inside the Combobox and on CheckBox_Checked(), I want apply that selected color to RadGridView specific row (in a particular cell of a row) based on RadGridView data value="High" and CheckBox is placed ouside the RadGridView?

Can you please help me to solve this case?

Thanks in advance..

VK

0
Bojjaiah
Top achievements
Rank 1
answered on 21 Feb 2011, 03:00 PM
hi,
I have Same functionlity if u know the code
reply this maiil
0
Joshua
Top achievements
Rank 1
answered on 21 Feb 2013, 04:14 PM
Hi,

I have a checkbox outside the radgridview. when user checked that i want to highlight the rows based on a condition.

Thanks,
Rajesh
0
Dimitrina
Telerik team
answered on 21 Feb 2013, 04:28 PM
Hello Rajesh,

To conditionally highlight the rows, you can use a RowStyleSelector as demonstrated on this online demo.

I hope this is what you are looking for.

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Joshua
Top achievements
Rank 1
answered on 21 Feb 2013, 07:27 PM
Didie,

Thanks for the quick reply. we are able to highlight the rows on intial load but what we need is..
 


Actually here is my scenario.

Intially we load the grid. and we have a checkbox outside the grid.
when we checked the checkbox i need to highlight the rows based on a condition.


Thanks,
Tags
GridView
Asked by
pv Upendran
Top achievements
Rank 1
Answers by
Milan
Telerik team
pv Upendran
Top achievements
Rank 1
V
Top achievements
Rank 1
Bojjaiah
Top achievements
Rank 1
Joshua
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or