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

Bring RowGroupDescriptions collapsed by default

11 Answers 143 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
Getulio
Top achievements
Rank 1
Getulio asked on 21 Jan 2013, 12:53 PM
Hi,

I'm using PivotGrid with LocalDataSourceProvider.
I'm defining RowGroupDescriptions and wanna that are collapsed in PivotGrid by default.

How can I achieve this?

Regards, Getulio.

11 Answers, 1 is accepted

Sort by
0
Rosen Vladimirov
Telerik team
answered on 21 Jan 2013, 02:16 PM
Hello Getulio,

Currently there isn't an easy way to achieve this. This feature is in our to-do list, but I cannot give you exact timeframe when it will be ready. If this is very important for your application, you can try this approach:
private DispatcherTimer dispTimer { get; set; }
 
public MainWindow()
{
    dispTimer = new DispatcherTimer();
    dispTimer.Interval = new TimeSpan(0, 0, 0, 0, 5);
    dispTimer.Tick += Each_Tick;
             
    InitializeComponent();       
}
 
private void LocalDataSourceProvider_StatusChanged_1(object sender, DataProviderStatusChangedEventArgs e)
{
    if (e.NewStatus == DataProviderStatus.Ready && e.ResultsChanged == true)
    {
        Dispatcher.BeginInvoke(() => dispTimer.Start());
    }
}
 
public void Each_Tick(object o, EventArgs sender)
{
    CollapseGroups();
    this.dispTimer.Stop();
}
 
private void CollapseGroups()
{
    foreach (IGroup group in this.radPivotGrid.RowGroups)
    {
        this.radPivotGrid.CollapseRow(group);
    }
 
    foreach (IGroup group in this.radPivotGrid.ColumnGroups)
    {
        this.radPivotGrid.CollapseColumn(group);
    }
 
    this.radPivotGrid.Refresh();
}

Please note that you'll have to use the StatusChanged event of your LocalDataSourceProvider:
<pivot:LocalDataSourceProvider x:Key="LocalDataProvider" StatusChanged="LocalDataSourceProvider_StatusChanged_1">

The idea of the code is to collapse all items on the top level when the Status of the DataProvider is Ready and the Data has changed. With the current release you have to use DispatcherTimer to do the trick. You should apply some tests and adjust it accordingly (based on the amount of your data - if you are not showing a lot of data 1ms will be enough, just for you assurance that everything will work as expected, I have set 5ms).

Please note that this is just a workaround for this problem, as I already said, we are working on this feature and in the future you'll have an easier way to decide whether the items will be collapsed or expanded.

Hopefully this helps. Feel free to contact us if you have any problems or concerns.

Kind regards,
Rosen Vladimirov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Getulio
Top achievements
Rank 1
answered on 22 Jan 2013, 02:42 PM
Hi Rosen,

Thanks for your response.
In fact I need less then you posted, but your post was great.
What I need is bring collapsed by default at first time.

I understud well your code but CollapseGroup method isn't working.
My LocalDataSourceProvider:

<pivot:LocalDataSourceProvider x:Key="GrupoEstabelecimentoDataProvider">

    <pivot:LocalDataSourceProvider.RowGroupDescriptions>
        <pivot:PropertyGroupDescription PropertyName="NomeEstabelecimento" CustomName="Loja" />
        <pivot:PropertyGroupDescription PropertyName="NomeFamilia" CustomName="Família" />
        <pivot:PropertyGroupDescription PropertyName="NomeItem" CustomName="Mercadoria" />
    </pivot:LocalDataSourceProvider.RowGroupDescriptions>
    <pivot:LocalDataSourceProvider.ColumnGroupDescriptions>
        <pivot:PropertyGroupDescription PropertyName="Periodo" CustomName="Período" SortOrder="Descending" />
    </pivot:LocalDataSourceProvider.ColumnGroupDescriptions>
    <pivot:LocalDataSourceProvider.AggregateDescriptions>
        <pivot:PropertyAggregateDescription PropertyName="QuantidadePedida" CustomName="Qtd. Pedida" />
        <pivot:PropertyAggregateDescription PropertyName="QuantidadeAtendida" CustomName="Qtd. Atendida" />
        <pivot:PropertyAggregateDescription PropertyName="QuantidadeCancelada" CustomName="Qtd. Cancelada" />
        <pivot:PropertyAggregateDescription PropertyName="Saldo" CustomName="Saldo" />
    </pivot:LocalDataSourceProvider.AggregateDescriptions>
</pivot:LocalDataSourceProvider>

In CollapseGroup  method this.radPivotGrid.RowGroups is returning no results.

Do you have any idea?



0
Rosen Vladimirov
Telerik team
answered on 22 Jan 2013, 02:56 PM
Hello Getulio,

RowGroups collection is filled asynchronous and it is very important when you are trying to execute your logic of collapsing the items. That's why I used a DispatcherTimer in the previously mentioned code. If you want to have the items collapsed only the first time, you can use the same approach:
public MainWindow()
{
    dispTimer = new DispatcherTimer();
    dispTimer.Interval = new TimeSpan(0, 0, 0, 0, 10);
    dispTimer.Tick += Each_Tick;
             
    InitializeComponent();
    dispTimer.Start();
}
 
public void Each_Tick(object o, EventArgs sender)
{
    Dispatcher.BeginInvoke(() => CollapseGroups());
    this.dispTimer.Stop();
}

And once again you'll have to adjust the DispatcherTimer based on the amount of your data.

We are sorry for the inconvenience caused. Hopefully above mentioned solution is acceptable for you until we provide easier way to do it.

Regards,
Rosen Vladimirov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Yuriy
Top achievements
Rank 1
answered on 27 Feb 2013, 05:07 PM
Hi Rosen,

The code above works fine in case you have only one PropertyAggregateDescription element. But, when I tried to use it with more than one - the CollapseColumn() isn't working, causing crash.

<pivot:LocalDataSourceProvider.AggregateDescriptions>
                    <pivot:PropertyAggregateDescription PropertyName="BudgetAmount" StringFormat="$0" />
                    <pivot:PropertyAggregateDescription PropertyName="AccruedAmount" StringFormat="$0" />
        </pivot:LocalDataSourceProvider.AggregateDescriptions>

Any suggestions?

Thank you,
-Yuriy
0
Rosen Vladimirov
Telerik team
answered on 28 Feb 2013, 11:59 AM
Hi Yuriy,

I'm sending you a project to illustrate how you can achieve this behavior. Please check it and inform us if you have any problems or concerns.

Greetings,
Rosen Vladimirov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Yuriy
Top achievements
Rank 1
answered on 28 Feb 2013, 03:31 PM
Hi Rosen,

Thank you for such a quick response. Your approach works great except one issue (you can see it in sample project you sent) - first few rows & columns have wrong expand/collapse icon, so it requires to click twice to expand column or row group . Can you look to it?

Thank you,
-Yuriy
0
Rosen Vladimirov
Telerik team
answered on 28 Feb 2013, 04:12 PM
Hello Yuriy,

I've already noticed this issue, but unfortunately we will need some time to investigate it. Also, as I've already said in the beginning of this thread, this is only a workaround - in the future we will provide an easier way to collapse the groups. In fact, I would ask all of you, to send us your expectations for this feature (you can write them in this forum thread) - would you like to collapse all groups or only some of them, would you like to collapse the groups only at the initialization of RadPivotGrid, but all other refreshes to create expanded groups or you would like to see only collapsed groups even after refresh. With your help we'll be able to provide the functionality you need.

I'm sorry for the caused inconvenience and I'm looking forward to hearing from you.

All the best,
Rosen Vladimirov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Per
Top achievements
Rank 1
answered on 08 Mar 2013, 10:17 AM
Hi,

I'm facing the same issue and really would like to have a CollapsedOnLoad="True" property on the Pivot.

/Per
0
Rosen Vladimirov
Telerik team
answered on 08 Mar 2013, 11:45 AM
Hi Per,

We are working on this feature and we'll try to push it for our ServicePack (I don't have the official date of the release). We'll definitely have it for our Q2 release, that's sure.

We are sorry for the caused inconvenience. Feel free to contact us if you have any other problems or concerns.

Kind regards,
Rosen Vladimirov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Gaurav
Top achievements
Rank 1
answered on 19 Apr 2016, 01:40 PM

Hello,

I am facing the same issue. I want to keep all rows and columns collapsed at startup by default. This way the data page load will also be faster. 

Pls suggest if this issue is resolved or not. Thanks

0
Polya
Telerik team
answered on 20 Apr 2016, 10:04 AM
Hi,

You would be able to initially collapse everything using an ExpandBehavior. Please check the following article that demonstrates how use the behavior:
http://docs.telerik.com/devtools/wpf/controls/radpivotgrid/features/expand-behavior.html

Regards,
Polya
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
PivotGrid
Asked by
Getulio
Top achievements
Rank 1
Answers by
Rosen Vladimirov
Telerik team
Getulio
Top achievements
Rank 1
Yuriy
Top achievements
Rank 1
Per
Top achievements
Rank 1
Gaurav
Top achievements
Rank 1
Polya
Telerik team
Share this question
or