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

Showing detail table on group

3 Answers 52 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Marc Van Pottelbergh
Top achievements
Rank 1
Marc Van Pottelbergh asked on 07 May 2010, 09:08 AM
Hello,

I just started working with the RadGrid and I have a question. Is it possible to bind a detail table to the grouping of the mastertable?
I'll explain my question with an example. Let's say we have following mastertable:

Order ID: 1 (grouping)
    record A 
        detail **
    record B
        detail **
    record C
        detail **
Order ID: 2 (grouping)
    record X
        detail --
        detail --
    record Y
        detail --
        detail --

Order ID: 3 (grouping)
    record Z

You'll notice that the records from the detail table are the same for every record under a certain group (e.g. Order ID 1).
Is it possible to let the detail table expand only once for each group, so to have following:

Order ID: 1 (grouping)
    record A 
    record B
    record C
        detail **

Thanks in advance for suggestions!!

Marc

3 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 11 May 2010, 04:58 PM
Hello Marc,

Unfortunately, nested tables are supported only for regular GridDataItems. You cannot nest detail tables under GridGroupHeader items. You can, however, collapse the data items that have repeating nested tables and hide their Expand/Collapse buttons. Thus, if you have 2 data items with identical nested tables, only the first data item will be expandable to show the detail table. The other 2 won't have their detail tables visible.

Let me know if that works for you. You can hide nested tables programmatically using Page_PreRender:

protected void Page_PreRender(object sender, EventArgs e)
{
    foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
    {
        if (item.ChildItem.NestedTableViews.Length > 0)
        {
            GridTableView nestedView = item.ChildItem.NestedTableViews[0];
            bool isIdentical = false;
            //check if nestedView is identical to any previous one and set isIdentical
            if (isIdentical)
            {
                item.Expanded = false;
                //hide the expand/collapse button
                item["ExpandColumn"].Controls[0].Visible = false;
            }
        }
    }
}


Kind regards,
Veli
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
0
Marc Van Pottelbergh
Top achievements
Rank 1
answered on 18 May 2010, 09:06 AM
Hey Veli,

Thanks for clearing out things a bit!

The code you provided can't work to my opinion because you left out the part where you need to check if the nestedview is identical to any previous one + setting the 'isIdentical' to true.
0
Veli
Telerik team
answered on 19 May 2010, 01:24 PM
Hello Marc,

Well, of course, as the comment suggests, this logic is omitted. How you recognize repeating data is beyond the scope of what I wanted to show, which is. how to hide the repeating detail tables.

It will be easier to recognize repeating data when it is retrieved. Particularly, if you are using SQL SELECT statements or some other expressions to request data from your persistence store, then you can check for repeating queries. 2 identical queries are guaranteed to return the same data, unless the data is modified by a third party.

Alternatively, you can compare data items when they are retrieved,  before the detail tables are databound. This is heavier that the first approach, but you can check each data value explicitly.

Finally, of course, you can wait for the detail tables to databind and compare the GridTableView instances (very heavy and probably unnecessary).

In any case, the implementation depends on your particular scenario.

Kind regards,
Veli
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Marc Van Pottelbergh
Top achievements
Rank 1
Answers by
Veli
Telerik team
Marc Van Pottelbergh
Top achievements
Rank 1
Share this question
or