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

Resizing Columns in a Hierarchical Grid (with Master table columns aligned with detail table columns)

3 Answers 288 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Saicharan
Top achievements
Rank 1
Saicharan asked on 29 Nov 2011, 02:10 PM
I am trying to achieve Grouping through RadGrid's Hierarchical Grid Functionality (Unlike the RadGrid's default grouping functionality - I'm trying to show the parent row or master table row containing one of the records from the group intact while expanding). In order to achieve this,  I've hidden the detail table's header and aligned the widths of each column of the detail table to that of the parent row/table (while merging all the common/grouped columns into one and displaying it blank). Now I'm facing two problems -
1. If resizing is enabled - resizing master table column does not automatically resize the detail table column. Is there any way to do such resizing from the client side.
2. I am using a custom Expand/Collapse column and I am unable to hide the default Expand/Collapse column. Is there a way to hide the default Expand/Collapse column of RadGrid?
3. If reorder is enabled - how to trigger column reorder of detail table when master table reorder occurs (in the client side)
Attached please find grid that demonstrates the functionality that I'm trying to achieve (I have masked party of the data due to privacy reasons)
Can you please help?

3 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 02 Dec 2011, 10:57 AM
Hi Saicharan,

Thank you for your description and the screen shot. On to your questions:

1. Yes. You need to use RadGrid's client-side OnColumnResized event to go through each of your detail tables and resize their respective columns:

<ClientEvents OnColumnResized="gridColumnResized"/>

function gridColumnResized(sender, args)
{
    var col = args.get_gridColumn();
    if (col.get_owner().get_id() !== sender.get_masterTableView().get_id())
    {
        //execute only for columns in the master table
        return;
    }
 
    var width = col.get_element().offsetWidth;
    var detailTables = sender.get_detailTables();
    for (var i = 0; i < detailTables.length; i++)
    {
        detailTables[i].resizeColumn(col.get_element().cellIndex, width);
    }
}

2. Yes. The built-in expand column can be hidden on the server in the PreRender event of the page or the control:

protected void Page_PreRender(object sender, EventArgs e)
{
    RadGrid1.MasterTableView.RenderColumns[0].Visible = false;
}

3. This scenario is not supported. Column reordering works for the master table only.

Greetings,
Veli
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
Saicharan
Top achievements
Rank 1
answered on 09 Dec 2011, 01:23 PM
I tried to resize detail table column based upon resize event on the master table but could not get it working.

The conditional statement below did not work as I have enabled scrolling with fixed headers.

if (col.get_owner().get_id() !== sender.get_masterTableView().get_id())

In order to get it working, I've removed scrolling on the grid. Then, the rest of the code gets executed properly but the detail table columns do not resize.
Can you please upload a solution or provide a link which demonstrates this?
0
Veli
Telerik team
answered on 12 Dec 2011, 05:36 PM
Hello Saicharan,

Unfortunately this scenario is not supported with static headers. You need to disable static headers in RadGrid and use standard scrolling. Attaching a test page to demonstrate the scenario. You can plug it in a project together with the sample data class and run it.

Veli
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
Tags
Grid
Asked by
Saicharan
Top achievements
Rank 1
Answers by
Veli
Telerik team
Saicharan
Top achievements
Rank 1
Share this question
or