Is there a way to display a row number on the row header? I have a hierarchical grid and like to display number of the row header. I don't want to add additional column to display row number, indead I like them to be on row header.
Thanks,
Amit
5 Answers, 1 is accepted
Will you please share with us what should be the exact desired result when the row number is displayed within GridViewHeaderRow? Imagine that you have 100 items and 10 columns, so what do you expect to see in this part of RadGridView? What you may do is to keep a separate column and transpose the rows into columns and vice versa. You may take a look at the following blog post which demonstrates how this can be achieved.
Vanya Pavlova
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Thanks,
Amit
Looking at your pictures I am not quite sure whether you refer either to RadGridView or TreeListView component. Will you please share with us a bit more info about your exact settings?
Any relevant snippet or sample project in a new support ticket might be of help on that matter.
Vanya Pavlova
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Thanks,
Amit
private void GridViewDataControl_RowLoaded(object sender, RowLoadedEventArgs e) {
var gridViewRow = e.Row as GridViewRow;}
if (gridViewRow != null)
{
var border = gridViewRow .ChildrenOfType<Border>() .Where(b => b.Name == "PART_IndicatorPresenter") .FirstOrDefault();
if (border != null)
{ var innerBorder = border.Child as Border;
if (innerBorder != null && !(innerBorder.Child is TextBlock))
{
var textBlock = new TextBlock();
textBlock.TextAlignment = TextAlignment.Center;
textBlock.VerticalAlignment = VerticalAlignment.Center;
textBlock.Text = (_target.Items.IndexOf(gridViewRow.Item) + 1).ToString();
innerBorder.Child = textBlock;
}
}
}
Generally the approach you have used is not the recommended one. RowLoaded event is fired each time a row appears within the viewport and you are adding visual elements to it. It would be much more appropriate to incorporate this TextBlock in the template of GridViewRow and set its Text property to the index of the corresponding item. I am attaching you sample project which demonstrates how this can be achieved.
Vanya Pavlova
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>