4 Answers, 1 is accepted
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.
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 >>
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 >>
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