Bring RowGroupDescriptions collapsed by default

12 posts, 0 answers
  1. Getulio
    Getulio avatar
    9 posts
    Member since:
    Jan 2013

    Posted 21 Jan 2013 Link to this post

    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.
  2. Rosen Vladimirov
    Admin
    Rosen Vladimirov avatar
    640 posts

    Posted 21 Jan 2013 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Getulio
    Getulio avatar
    9 posts
    Member since:
    Jan 2013

    Posted 22 Jan 2013 Link to this post

    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?



  5. Rosen Vladimirov
    Admin
    Rosen Vladimirov avatar
    640 posts

    Posted 22 Jan 2013 Link to this post

    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.

  6. Yuriy
    Yuriy avatar
    9 posts
    Member since:
    Jan 2012

    Posted 27 Feb 2013 Link to this post

    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
  7. Rosen Vladimirov
    Admin
    Rosen Vladimirov avatar
    640 posts

    Posted 28 Feb 2013 Link to this post

    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.

  8. Yuriy
    Yuriy avatar
    9 posts
    Member since:
    Jan 2012

    Posted 28 Feb 2013 Link to this post

    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
  9. Rosen Vladimirov
    Admin
    Rosen Vladimirov avatar
    640 posts

    Posted 28 Feb 2013 Link to this post

    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.

  10. Per
    Per avatar
    1 posts
    Member since:
    Mar 2013

    Posted 08 Mar 2013 Link to this post

    Hi,

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

    /Per
  11. Rosen Vladimirov
    Admin
    Rosen Vladimirov avatar
    640 posts

    Posted 08 Mar 2013 Link to this post

    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.

  12. Gaurav
    Gaurav avatar
    1 posts
    Member since:
    Sep 2015

    Posted 19 Apr in reply to Rosen Vladimirov Link to this post

    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

  13. Polya
    Admin
    Polya avatar
    199 posts

    Posted 20 Apr Link to this post

    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.
Back to Top
UI for WPF is Visual Studio 2017 Ready