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

How to expand one level on each click when all row fields are collapsed initially

15 Answers 691 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 20 Mar 2013, 08:00 PM
I have 4 row fields defined in RadPivotGrid. I made all row fields colapsed initially by set RowGroupsDEfaultExpanded attribute to false. But once I click the expand button on top level, it expands all 4 level for me, but I expect just expand level 2. Is there any way to change it? Thanks.

15 Answers, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 25 Mar 2013, 05:55 PM
Hi Richard,

Thank you for contacting us.

In order to achieve the desired goal you will have to use the CollapseAllRowGroups server-side method of the RadPivotGrid. You can use the code from the code snippet below to prevent the expanding of the 2nd and 3rd level of the hierarchy:
protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);
        RadPivotGrid2.CollapseAllRowGroups(1,false);
    }

More information about this method and how it works you can find here.

Let me know if I could assist you further.

Kind regards,
Angel Petrov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Tanvir
Top achievements
Rank 1
answered on 01 Jan 2014, 02:37 PM
I am having two issues with telerik Pivot Grid. 

1) Throws error when i try to collapse or expand the row(s). Is there an event i can handle on server side ?
2) On load for the first time Grid do not size the columns correctly. when i refresh it works okay.

Thank you.
Tanvir Shaikh
0
Angel Petrov
Telerik team
answered on 06 Jan 2014, 09:40 AM
Hi Tanvir,

The behavior experienced is not expected. However it is difficult to provide a precise answer on why does it occur without having a better view over the setup. That said could you please share with us the markup and code-behind of the pivot page so we could investigate further.

As for intercepting the expand/collapse I suggest subscribing to the OnItemCommand event like demonstrated below:

C#:
protected void RadPivotGrid1_ItemCommand(object sender, PivotGridCommandEventArgs e)
    {
        if(e.CommandName=="ExpandCollapse")
        {
        }
    }


Regards,
Angel Petrov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Tanvir
Top achievements
Rank 1
answered on 06 Jan 2014, 01:07 PM
I was able to resolved the issue by refreshing the data. It seems like some how the rows were getting lost.
I did check the view state and it is enabled.

If you have a better solution do send it to me.
Thank you for your help.

C#:
protected void RadPivotGrid1_ItemCommand(object sender, PivotGridCommandEventArgs e)
    {
        if(e.CommandName=="ExpandCollapse")
        {
              LoadRadPivotGrid();
        }
    }
0
Angel Petrov
Telerik team
answered on 09 Jan 2014, 09:50 AM
Hello Tanvir,

I am glad that you were able to resolve the problem on hand. However note that you should not had experienced such behavior. If you can provide us with the markup and code-behind of the page we will investigate further what might be causing it.

Regards,
Angel Petrov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Prabhu
Top achievements
Rank 1
answered on 02 Apr 2014, 10:58 AM
Hi ,
In RadPivotGrid control  expand and collapse for column its expand all fields.. for example you've 3 sub field  one by one. its expand and collapse  all column but i need  expand all column  don't collapse  last two fields ...

that means how to hide collapse single column(row) in RadPivotGrid.. Reply ASAP
0
Prabhu
Top achievements
Rank 1
answered on 04 Apr 2014, 07:29 AM
Please can you tell me how to hide collapse and expand image in radpivotgrid  in second field
0
Angel Petrov
Telerik team
answered on 07 Apr 2014, 07:02 AM
Hello Prabhu,

For hiding the column header expand button you can subscribe to the OnCellDataBound and execute the following logic.

C#:
protected void RadPivotGrid1_CellDataBound(object sender, PivotGridCellDataBoundEventArgs e)
    {
        
        PivotGridColumnHeaderCell columnHeader = e.Cell as PivotGridColumnHeaderCell;
        if (columnHeader != null)
        {
            if (columnHeader.Controls.Count > 0 && columnHeader.ParentIndexes.Count() > 1)
            {
                (columnHeader.Controls[0] as Button).Visible = false;
            }
        }
    }

If needed the same can also be applied for the row header cells as demonstrated below.

C#:
protected void RadPivotGrid1_CellDataBound(object sender, PivotGridCellDataBoundEventArgs e)
    {
        PivotGridRowHeaderCell rowHeader = e.Cell as PivotGridRowHeaderCell;
        if (rowHeader != null)
        {
            if (rowHeader.Controls.Count > 0 && rowHeader.ParentIndexes.Count() > 1)
            {
                (rowHeader.Controls[0] as Button).Visible = false;
            }
        }
    }


Regards,
Angel Petrov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Prabhu
Top achievements
Rank 1
answered on 09 Apr 2014, 06:19 AM
Hello,
 I've more than three sub header in pivodgrid  when i click 1st headercell its show next header with collapse button then others.. like to end...

but i need , when i'm  expand 1st click in header its show all sub header  upto datafield without expand/collapse button.. is it possible...
please tell me soon
0
Angel Petrov
Telerik team
answered on 14 Apr 2014, 06:40 AM
Hi Prabhu,

Actually by integrating the approach which I provided in my previous post you should be able to hide the expand/collapse buttons as you can see from this video. Am I not understanding the requirement correctly?

If you want to hide the expand collapse buttons for the parent headers as well you should modify the logic like demonstrated below:

C#:
void pivotGrid_CellDataBound(object sender, PivotGridCellDataBoundEventArgs e)
   {
       PivotGridColumnHeaderCell columnHeader = e.Cell as PivotGridColumnHeaderCell;
       if (columnHeader != null)
       {
           if (columnHeader.Controls.Count > 0)
           {
               (columnHeader.Controls[0] as Button).Visible = false;
           }
       }
       PivotGridRowHeaderCell rowHeader = e.Cell as PivotGridRowHeaderCell;
       if (rowHeader != null)
       {
           if (rowHeader.Controls.Count > 0)
           {
               (rowHeader.Controls[0] as Button).Visible = false;
           }
       }
   }


Regards,
Angel Petrov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Prabhu
Top achievements
Rank 1
answered on 15 Apr 2014, 01:27 PM
Thanks a lot Angel...

1.could you tell me how to default only one column expand when page load... ?
2. how to use label to that given expanded row in  the right side of the pivotgrid..?

ref:Attached image
0
Prabhu
Top achievements
Rank 1
answered on 16 Apr 2014, 05:05 AM
Hi Friends..
I've two  question .Could you tell me  any one please

1. how to default only one column expand when page load... ?
2. how to use label to that given expanded row in  the Left side of the pivotgrid..?

ref:Attached image
0
Angel Petrov
Telerik team
answered on 18 Apr 2014, 09:45 AM
Hello Prabhu,

In order to expand only one column you can set ColumnGroupsDefaultExpanded to true and add the column fields in the CollapsedColumnIndexes collection. For example:
protected override void OnPreRender(EventArgs e)
    {
        
        base.OnPreRender(e);
        RadPivotGrid1.ColumnGroupsDefaultExpanded = true;
        RadPivotGrid1.CollapsedColumnIndexes.Add(new string[] { "2015","2016" });
        RadPivotGrid1.Rebind();
    }
should collapse 2015 and 2016 if present.

As for adding labels in the row headers zone I would not recommend it as this might break the layout and functionality of the control. That said I would suggest revising the requirement.

Regards,
Angel Petrov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Prabhu
Top achievements
Rank 1
answered on 21 Apr 2014, 10:04 AM
Hi friends...
Is it possible to create Editable pivot grid with expand & collapse in telerik ?
if its there please send me sample code  to my mail.
0
Angel Petrov
Telerik team
answered on 24 Apr 2014, 06:48 AM
Hello Prabhu,

I am sorry to say but such functionality is currently not supported and I am not sure that it will be included in a future release. The problem is that the pivot displays aggregated values and it is hard to determine which values in the database should get updated once the user tries to submit the changes. If however you have something specific in mind I would recommend logging it into our feedback portal.

Regards,
Angel Petrov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
PivotGrid
Asked by
Richard
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Tanvir
Top achievements
Rank 1
Prabhu
Top achievements
Rank 1
Share this question
or