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

many-to-many hierarchy

2 Answers 237 Views
Grid
This is a migrated thread and some comments may be shown as answers.
PureCode
Top achievements
Rank 2
PureCode asked on 31 Jan 2008, 11:39 PM
I have a normal master table, and I need to add a number of detail tables to this. Each detail table is a many-to-many relationship to the master table, so i have junction tables in between them.

How on earth do i set up the grid to show me the detail tables, using the junction tables, and all of that using separate sqldatasources? (I started out with ALL the tables in a single sqldatasource, but even the master won't work correctly then with it's large number of lookup drop downs, etc).. I have to admit that the RadGrid has me pretty much scratching my head 24/7 by now, been jumping through too many hoops to get things to work right, quite frustrating!

The documentation, samples and demos are pretty much useless in regards to most 'more advanced' uses of the RadGrid as well. It is costing me way too much time to get things done, even delete and update of records in the master didn't work right because of the sqldatasource generating entirely incorrect SQL (which one does not expect).

I literally have NO clue what i am doing with that property builder (which 'forgets' datasources all over the place, sometimes does see the columns but usually not, NEVER sees columns in detail tables with a diffferent datasource (which it, of course, forgets most of the time), setting the datasource in the builder doesn't update the datasource at all, etc). It naming detail tables after the datamember is ridiculous as well, since there is a 'Name' property..

This too seems 'incomplete', too many 'basic' things not working as they should or are completely illogical.

I am starting to get extremely frustrated with Prometheus by now, if RadControls for ASP.NET didn't have 5 zillion dll's and massive amounts of external scripts, skins, etc I would try that, but i fear it'll just result in the same thing.

I really don't get what is so hard to simply hang the complete database to a grid, it automatically resolving all the relationships and creating all the detail tables automatically, while, of course, allowing on to select what to show and what not. Simple and straightforward, not doing EVERYTHING by hand like it seems RadGrid works now (which is not exactly 'Rad').

2 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 04 Feb 2008, 02:17 PM
Hello,

Basically, the creation of the hierarchy is pretty straightforward, but a few important settings and relations must be observed. Basic information on the hierarchical structure can be found in this article, as well as this one.
The first example which shows the contro's hierarchical structure in practice is this one. Based on it, there are a few important properties to be set:

.aspx
 <rad:RadGrid ID="RadGrid1" Skin="WebBlue" DataSourceID="AccessDataSource1" runat="server" 
Width="95%" AutoGenerateColumns="False" 
            PageSize="3" AllowSorting="True" 
AllowMultiRowSelection="False" AllowPaging="True" GridLines="None">  
            <PagerStyle Mode="NumericPages"></PagerStyle> 
            <ClientSettings AllowExpandCollapse="True">  
            </ClientSettings> 
            <MasterTableView DataSourceID="AccessDataSource1" DataKeyNames="CustomerID" 
AllowMultiColumnSorting="True" 
                HierarchyLoadMode="Client" Width="100%">  
                <DetailTables> 
                    <rad:GridTableView DataKeyNames="OrderID" DataSourceID="AccessDataSource2" Width="100%" > 
                        <ParentTableRelation> 
                            <rad:GridRelationFields DetailKeyField="CustomerID" MasterKeyField="CustomerID" /> 
                        </ParentTableRelation> 
 

As shown in the code snippet above, the mastertableview is with a standard declaration, including its column. The DetailTables collection will hold a recursive set of detail tables. That is, you can have DetailTables, nested in other detail tables. For each detail table, there are two important settings to include. First, is the DataKeyNames, and then ParentTableRelation. Essentially, the parent table relation establishes the connection between the master key field and the detail field, which will be matched to determine how to create the hierarchy. Additionally, this example shows a hierarchy with automatic operations enabled for it. The logic remains pretty much the same, the only difference is that there are update/delete parameters in the underlying datasources, to facilitate the functionality. Another resource which could be of use is this movie, which shows the basic set of steps, needed to create the hierarchy.
Indeed, as you mentioned in your post, there is no option to simply pass the datasource to the control, and have it automatically resolve the relations and build the hierarchy. I hope the present setup is not very unintuitive for you, and meets your requirements, after setting the properties, needed to allow the grid to create its structure properly. Any additional feedback, on how we could improve, and make the product more intuitive, is also welcome.
Further. if any specific issues arise, please feel free to open a formal support ticket, and send us the relevant code, for further reviewing.

All the best,
Yavor
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
PureCode
Top achievements
Rank 2
answered on 04 Feb 2008, 07:12 PM
Thanks for the info, I'll be sure to give that another try :)

Apologies for the 'rant', btw, re-read it and it sounds a bit harsh, not meant as such really. Been very busy lately.

Thanks,

Mike
Tags
Grid
Asked by
PureCode
Top achievements
Rank 2
Answers by
Yavor
Telerik team
PureCode
Top achievements
Rank 2
Share this question
or