Group header row color

3 posts, 0 answers
  1. yaron
    yaron avatar
    2 posts
    Member since:
    Jun 2015

    Posted 22 Jan Link to this post

    Hi,

    I have a grouped radgridview.

    What I am trying to accomplish is, when a regular (not group row) row is selected, I would like to change the background color of it's group row so it will be easy to see it (the group row of the selected regular row).

    For example - 

    Group Row A

    1

    2

    3

    Group Row B

    4

    5

    if the user selects the row "2" I want "Group Row A" to change color. If the user then selects row "4" I want "Group row B" to change color (and "Group Row A" to change back to it's default color).

     

    I have succeeded to change the color of the group row when selecting the group row directly (through the ViewRowFormatting event) but can not do it in a good way when a regular row is selected (in the SelectionChnaged event). I tried using:

    1) From SelectionChanged event calling  this.gridView.TableElement.Update(GridUINotifyAction.Reset) but it brings the table back to the top if the user scrolled down.

    2) From SelectionChanged  - tried to get the group row of the selected row and change it's background. Can not find the way to get to the GroupRowElement where I can access the background property.

    Please help, any advice to achieve this would be appreciated!

    Yaron

     

     

  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3818 posts

    Posted 27 Jan Link to this post

    Hello, Yaron,  

    The appropriate place to format the grid cells/rows is to use the ViewCellFormatting/ViewRowFormatting events, not the SelectionChanged event. In other events you can just mark certain data rows for highlighting, e.g. via the data row's Tag property and then use this Tag value in the formatting event that you are using. The following help articles demonstrate how to customize the grid cells/rows:
    https://docs.telerik.com/devtools/winforms/controls/gridview/cells/formatting-cells 
    https://docs.telerik.com/devtools/winforms/controls/gridview/rows/formatting-rows 

    If you need to trigger firing the event for a certain row, it is necessary to call the InvalidateRow method for the respective data row. Calling the MasterTemplate.Refresh method will reset the view and the vertical scrollbar will go to the top. You can keep the vertical scrollbar's value before refreshing and restore its value after that. It is necessary to store the TableElement.VScrollBar.Value property and restore it later.

    I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

    Regards,
    Dess | Tech Support Engineer, Sr.
    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.
  3. Varda Gil
    Varda Gil avatar
    1 posts
    Member since:
    Jan 2020

    Posted 27 Jan in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Thank you for the tips and clarifications.

    I will use the info you gave me and hopefully I will succeed.

    Thanks again

Back to Top