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

Hierarchy grid + pivoted data + rebind problem

4 Answers 148 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ANDREW
Top achievements
Rank 1
ANDREW asked on 16 Dec 2011, 07:48 AM
Hi Folks,

I've come across a problem with the RadGrid where after rebinding, the child columns of an auto-generated hierarchy grid do not update with the new column specifications from the data bind (because the columns are changing in the pivoted data).

Below is the definition of the RadGrid. As you can see the columns are not defined and instead generated automatically on binding (given that they are not known until after having been bound, and does also change depending on the pivot grouping query)

<telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="ObjectDataSource1" OnColumnCreated="RadGrid1_ColumnCreated" OnItemCreated="RadGrid1_ItemCreated" OnItemDataBound="RadGrid1_ItemDataBound">
    <MasterTableView HierarchyDefaultExpanded="false" HierarchyLoadMode="Client" AllowSorting="false" DataKeyNames="TypeId, ParentTypeId" Width="100%">
        <SelfHierarchySettings ParentKeyName="ParentTypeId" KeyName="TypeId" />
    </MasterTableView>
    <ClientSettings AllowExpandCollapse="true" />
</telerik:RadGrid>

As an example, if the grid is initially bound using pivoted data grouped by year (say 2009, 2010 and 2011 columns - as well as TypeId, ParentTypeId and a row description field) then a rebind occurs where the new pivoted data is grouped by month, the mastertable autogeneratedcolumns will be correct (say Jan09, Feb09... Dec11 etc) however each of the nested view columns will contain the original year grouped columns (2009, 2010, 2011 etc).

I've spent days searching for anyone with a similar problem but can't find anything. Is there anyway to force the nested views to rebind when the grid/mastertableview rebinds? Or is there any way to flush the existing autogenerated nested view columns so they will be regenerated during the rebind?

The problem that this rebinding issue creates is such that if the pivot query is continued to be grouped by year but the period changes (such that say 2009 is no longer returned in the result dataset), the table header will update correctly, however the expanded nested view will not be aligned as it leaves space as if 2009 is still there. In the generated HTML the extra <td> can be seen in the row. This is even more obvious when multiple years are removed. I have 'got around' the first problem by simply iterating over the nested view columns and hiding any child columns that should no longer be shown. However, if the grouping period for the pivot query is changed (to by the month instead of year) as previously stated, the auto-generated nested view columns remain with the original year column definitions and as such NO data is shown in the grid given that the columns no longer have anything to match to when binding.

Please let me know if you need any additional information.

Cheers,

Andrew

4 Answers, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 20 Dec 2011, 12:26 PM
Hi Andrew,

When a Rebind() is called for the grid, its whole structure is recreated based on the provided data. However, note that the control does not support hierarchical structure with pivoted data.

Have you considered using Telerik Reporting for the purpose of your project. It currently offers more advanced features related to displaying pivoted data:
http://demos.telerik.com/reporting/product-sales/demo.aspx

Kind regards,
Tsvetina
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
ANDREW
Top achievements
Rank 1
answered on 03 Jan 2012, 12:00 AM
Hi Tsvetina,

It seems from my testing that calling Rebind doesn't recreate the whole structure as the child hierarchy columns aren't recreated! Ignoring the fact that I am displaying pivoted data, this part of the RadGrid is either broken and missing the ability to have the child hierarchy columns rebound. If I was displaying some other data where the columns I wanted to show was dynamic and update-able on postback this would not work!

I appreciate your suggestion for alternative options but I have already spent considerable time building this page (and others) around the RadGrid and aside from this issue it is working exactly how I would like.

Thanks,

Andrew
0
Tsvetina
Telerik team
answered on 03 Jan 2012, 04:44 PM
Hi Andrew,

Isolated from the pivot table scenario, there is indeed a design limitation in the self-referencing hierarchy grid, because of which the child tables' columns do not get recreated on rebind - they are copied from the ViewState. So, changing the columns on postback in a self-referencing grid is not supported in a scenario with enabled ViewState. The only workaround is to wrap the grid in a Panel (or other container control) with disabled ViewState.
Let us know if you have further questions on this matter.

Kind regards,
Tsvetina
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
ANDREW
Top achievements
Rank 1
answered on 04 Jan 2012, 12:08 AM
Hi Tsvetina,

Ok I understand. I don't quite get why they couldn't be recreated from the columns of the master table view but it must be something important..

Thank you for your suggestion. I will have to weigh up the cost/benefits but given that I need to do a full rebind anyway it doesn't seem like such a big deal.

Cheers,

Andrew
Tags
Grid
Asked by
ANDREW
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
ANDREW
Top achievements
Rank 1
Share this question
or