RadGridView row color if the checkbox is checked

9 posts, 0 answers
  1. pv Upendran
    pv Upendran avatar
    10 posts
    Member since:
    Sep 2009

    Posted 10 Sep 2009 Link to this post

    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
  2. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 10 Sep 2009 Link to this post

    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.
  3. pv Upendran
    pv Upendran avatar
    10 posts
    Member since:
    Sep 2009

    Posted 11 Sep 2009 Link to this post

    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.
  4. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 16 Sep 2009 Link to this post

    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.
  5. V
    V avatar
    1 posts
    Member since:
    Jan 2011

    Posted 26 Jan 2011 Link to this post

    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

  6. Bojjaiah
    Bojjaiah avatar
    2 posts
    Member since:
    Oct 2010

    Posted 21 Feb 2011 Link to this post

    hi,
    I have Same functionlity if u know the code
    reply this maiil
  7. Joshua
    Joshua avatar
    22 posts
    Member since:
    Sep 2010

    Posted 21 Feb 2013 Link to this post

    Hi,

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

    Thanks,
    Rajesh
  8. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 21 Feb 2013 Link to this post

    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.

  9. Joshua
    Joshua avatar
    22 posts
    Member since:
    Sep 2010

    Posted 21 Feb 2013 Link to this post

    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,
Back to Top