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

Show row numbers

5 Answers 79 Views
PivotGrid and PivotFieldList
This is a migrated thread and some comments may be shown as answers.
Jens
Top achievements
Rank 1
Jens asked on 29 Sep 2015, 12:32 PM

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

5 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 30 Sep 2015, 01:06 PM
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
0
Jens
Top achievements
Rank 1
answered on 01 Oct 2015, 08:01 AM

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

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 01 Oct 2015, 02:17 PM
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
0
Jens
Top achievements
Rank 1
answered on 02 Oct 2015, 08:49 AM

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

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 05 Oct 2015, 08:15 AM
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
Tags
PivotGrid and PivotFieldList
Asked by
Jens
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Jens
Top achievements
Rank 1
Share this question
or