Show row numbers

6 posts, 0 answers
  1. Jens
    Jens avatar
    19 posts
    Member since:
    Aug 2014

    Posted 29 Sep 2015 Link to this post

    Hey,

    is there a way to display row / group numbers?

    Let's say i have three RowGroupDescriptions, i want to start numbering each top level group.

    Cheers,

    Jens

  2. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 30 Sep 2015 Link to this post

    Hello Jens,

    Thank you for writing.

    It is suitable to use the RadPivotGrid.GroupElementFormatting event where you can specify the desired text for the PivotGroupElementEventArgs.CellElement and achieve the required numbering. You can refer to the PivotGrid >> Formatting appearance help article for additional information.

    I hope this information helps. Should you have further questions I would be glad to help.
     
    Regards,
    Dess
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Jens
    Jens avatar
    19 posts
    Member since:
    Aug 2014

    Posted 01 Oct 2015 in reply to Dess Link to this post

    Hey Dess,

    thanks, thats a nice way to inject some text.

    But how to get the indices for the top level groups? I've tried GroupElement.Data.Index, but that results in in numbering all sub groups. In the screenshot the red numbers show my "targeted numbering" ;)

    Cheers,

    Jens

  5. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 01 Oct 2015 Link to this post

    Hello Jens,

    Thank you for writing back.

    You can access the GroupElement.Data.Group.Level and apply the numbering only to the desired level. Thus, in a counter you can store the number:
    int cnt = 1;
     
    private void radPivotGrid1_GroupElementFormatting(object sender, Telerik.WinControls.UI.PivotGroupElementEventArgs e)
    {
        if (e.GroupElement.Data.Group.Level == 0)
        {
            e.GroupElement.Text = string.Format("{0}.{1}", cnt, e.GroupElement.Text);
            cnt++;
        }
    }

    I hope this information helps. If you have any additional questions, please let me know.

    Regards,
    Dess
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  6. Jens
    Jens avatar
    19 posts
    Member since:
    Aug 2014

    Posted 02 Oct 2015 in reply to Dess Link to this post

    Hey Dess,

    The Formatting Event is called multiple times due to Re(paint) events, so you end up with very wrong numbers after scrolling ^^

    Cheers,

    Jens

  7. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 05 Oct 2015 Link to this post

    Hello Jens,

    Thank you for writing back.

    You can use a Dictionary to store the correct number for the GroupElement. Thus, when scrolling, you can use the stored value, instead of increasing the counter. Here is a sample a code snippet:
    int cnt = 1;
    Dictionary<object, string> numbers = new Dictionary<object, string>();
     
    private void radPivotGrid1_GroupElementFormatting(object sender, Telerik.WinControls.UI.PivotGroupElementEventArgs e)
    {
        if (e.GroupElement.Data.Group.Level == 0 && e.GroupElement.Parent.Class == "RowsContainer")
        {
            if (numbers.ContainsKey(e.GroupElement.Data))
            {
                e.GroupElement.Text = string.Format("{0}.{1}", numbers[e.GroupElement.Data], e.GroupElement.Text);
            }
            else
            {
                e.GroupElement.Text = string.Format("{0}.{1}", cnt, e.GroupElement.Text);
                numbers.Add(e.GroupElement.Data, cnt.ToString());
                cnt++;
            }
        }
    }

    Note that this is just a sample approach and it may not cover all possible cases. Feel free to modify it in a way which suits your requirement best.

    I hope this information helps. If you have any additional questions, please let me know.

    Regards,
    Dess
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for WinForms is Visual Studio 2017 Ready