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

DetailTables at Same Level - Same DataSource?

1 Answer 100 Views
Grid
This is a migrated thread and some comments may be shown as answers.
DMattingly
Top achievements
Rank 2
DMattingly asked on 28 Feb 2012, 02:42 PM
I've got a master grid with a parameter row that has several detail grids, all tied to the master. Currently, there's a stored proc that returns the data for all of these grids in a single resultset. When I was using a single Detailtable with a GroupByFields, the grids would split themselves out by that breakout field beautifully. But I've found out that the child grids need to have different sets of columns based on the type of breakout that it is.

Initially, I had done this by hiding all of the columns, and only making it visible if that particular breakout needed to show it. But that just gave me a wide list of columns that were mostly empty, since most of the columns did not apply to every breakout type.

I see that I can create a separate detail grid for each type of breakout, and attach a separate SqlDataSource to each one, but since the DataBind method does not work there, it's going to make the process lengthy and difficult. Is there a way to attach the entire set of detail tables to a single stored proc call (returning either a single resultset or one per breakout), and only map out a single detailtable on the front page?

I've got 17 different breakout detailtables, with column spreads something like this:
Type 1: Col 1, 2, 3, 4
Type 2: Col 2, 3, 4, 5
Type 3: Col 5, 6, 7, 8
Type 4: Col 1, 3, 6

Originally, I had every possible column returning, and would only show the ones I needed. The code was relatively compact and clean at that point. Elegant, really. I'd like to find a way to keep that clean codebase if possible.

1 Answer, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 02 Mar 2012, 01:11 PM
Hi,

In order to use just a single call to the datatable instead of calls for each separate level the best option would be to in the RadGrid OnNeedDataSource event to fill a DataSet with the needed tables and assign those tables to the RadGrid and respectively to the Datatables per your needs.
You could also review the following online example which demonstrates similar approach without using the grouping feature:
http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/twotablesatlevel/defaultcs.aspx


All the best,
Maria Ilieva
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
DMattingly
Top achievements
Rank 2
Answers by
Maria Ilieva
Telerik team
Share this question
or