IndentCell Style Selector

5 posts, 0 answers
  1. Juares Rigotti
    Juares Rigotti avatar
    15 posts
    Member since:
    Oct 2009

    Posted 05 Sep 2011 Link to this post

    It's possible create a Style Selector to alternate IndentCell? image attach.   
  2. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 05 Sep 2011 Link to this post

    Hi Eduardo Bonato,

     

    If you take a look at the default template of GridViewRow you may see a PART_IndentPresenter, which is responsible to display GridViewIndentCell in each row. Actually you do not have direct access to the IndentCells from the template of GridViewRow. Once you have accessed a particular row, find the GridViewIndentCells contained in it using the ChildrenOfType extension method and set the corresponding style.



    Kind regards,
    Vanya Pavlova
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  3. Juares Rigotti
    Juares Rigotti avatar
    15 posts
    Member since:
    Oct 2009

    Posted 05 Sep 2011 Link to this post

    You can send a example of how to I can proced?
  4. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 06 Sep 2011 Link to this post

    Hello Eduardo,

     

    The snippet below demonstrates a possible way to achieve the desired result:

    private void radGridView_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e)
           {
               if (e.Row is GridViewRow && !(e.Row is GridViewNewRow))
               {
                   Employee person = e.DataElement as Employee;
                   if (person.Age < 30)
                   {
                       (e.Row.ChildrenOfType<GridViewIndentCell>().ToList()).ForEach(c => c.Background = new SolidColorBrush(Colors.Red));
                   }
                   else
                   {
                       (e.Row.ChildrenOfType<GridViewIndentCell>().ToList()).ForEach(c => c.Background = new SolidColorBrush(Colors.Orange));
                   }
               
           }


    Fell free to change it in the way you need. 


    Regards,
    Vanya Pavlova
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  5. Mark
    Mark avatar
    4 posts
    Member since:
    Feb 2013

    Posted 02 Aug 2013 Link to this post

    This example was exactly what I needed. Thanks!

    Is there any way given this code to allow for the width of the GridViewIndentCell to be wider? We're looking to do this to allow for further indenting rows on a conditional basis. I tried this:

    (e.Row.ChildrenOfType<GridViewIndentCell>().ToList()).ForEach(c => c.Width = 100);

    But this leaves a bunch of white space to the level of the Indent Cell.

    Thanks,
    Mark
Back to Top