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

IndentCell Style Selector

4 Answers 36 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Juliano Ramos
Top achievements
Rank 1
Juliano Ramos asked on 05 Sep 2011, 08:59 PM
It's possible create a Style Selector to alternate IndentCell? image attach.   

4 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 05 Sep 2011, 09:13 PM
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 >>

0
Juliano Ramos
Top achievements
Rank 1
answered on 05 Sep 2011, 09:38 PM
You can send a example of how to I can proced?
0
Vanya Pavlova
Telerik team
answered on 06 Sep 2011, 07:44 AM
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 >>

0
Mark
Top achievements
Rank 2
answered on 02 Aug 2013, 04:45 PM
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
Tags
GridView
Asked by
Juliano Ramos
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Juliano Ramos
Top achievements
Rank 1
Mark
Top achievements
Rank 2
Share this question
or