Display row number on the row header

6 posts, 0 answers
  1. Amit Patel
    Amit Patel avatar
    71 posts
    Member since:
    Sep 2009

    Posted 28 Nov 2011 Link to this post

    Hello,
    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
  2. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 29 Nov 2011 Link to this post

    Hello Amit Patel,


     
    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.
     
     


    Kind regards,
    Vanya Pavlova
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. Amit Patel
    Amit Patel avatar
    71 posts
    Member since:
    Sep 2009

    Posted 29 Nov 2011 Link to this post

    It simply comes to down to usability issue. When two people open same file at separate locations, it’s easy to tell other what row they are working on. I have managed to pull off displaying row number, but seeing some weirdness when grid is hierarchical, the row numbers keep on increasing. See the attached images. I do now want to add another column to display row number, I think; it will just take extra real estate. I want it to look just like excel.

    Thanks,
    Amit
  4. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 29 Nov 2011 Link to this post

    Hi Amit Patel,


    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. 


    All the best,
    Vanya Pavlova
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  5. Amit Patel
    Amit Patel avatar
    71 posts
    Member since:
    Sep 2009

    Posted 05 Jan 2012 Link to this post

    Here is the code that I put it on gridview rowloaded event to add row number. if I am loading let say 1000 rows then row number are not displayed in correct order. It seems that RowLoaded event doesn't get fire in same order.  Can you tell me what would good way to do this?

    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;
                            }
                    }    
            }
    }
  6. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 05 Jan 2012 Link to this post

    Hi,

     

    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.  



    Greetings,
    Vanya Pavlova
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top