I am converting an application from a dataset bind of master-child-grandchild to a tuple of collections:
I am stuck trying to figure out how to do the binding between the lists to setup the master detail relationships.
Here is what I have ... showing the new code I have and the old code...
Tuple<List<UserClaimViewDto>, List<DocumentViewDto>, List<DocumentPageViewDto>> msg = VSCS.UserClaims.UserClaims.GetUserClaims2(historyDate, showAll); var UserClaims = new BindingList<UserClaimViewDto>( msg.Item1 ); var documents = new BindingList<DocumentViewDto>( msg.Item2); var pages = new BindingList<DocumentPageViewDto>(msg.Item3);
//??? // grdUserClaims.DataBindings.Clear(); // grdUserClaims.DataBindings.Add("Text", UserClaims, "UserClaimId"); // grdUserClaims.DataSource = UserClaims;
//dataset based code var messages = m_objMessages.GetUserClaimMessages(historyDate, showAll); // create producer/batch count relationship and add to DataSet DataColumn[] dclParent = new DataColumn[1]; DataColumn[] dclChild = new DataColumn[2]; DataColumn[] dcldocumentPages = new DataColumn[2];
dclParent[0] = messages.Tables[0].Columns["UserClaimId"];
dclChild[0] = messages.Tables[1].Columns["UserClaimId"]; dclChild[1] = messages.Tables[1].Columns["DocumentId"];
dcldocumentPages[0] = messages.Tables[2].Columns["UserClaimId"]; dcldocumentPages[1] = messages.Tables[2].Columns["DocumentId"];
DataRelation relContractHistory = new DataRelation("userClaim", dclParent[0], dclChild[0]); messages.Relations.Add(relContractHistory);
DataRelation relDocumentPages = new DataRelation("Pages", dclChild, dcldocumentPages); messages.Relations.Add(relDocumentPages);
grdUserClaims.DataSource = messages;
Hello,
Thank you for contacting Infragistics. I am no expert with Tuples but I am pretty sure you need to use linq and create a query and "toList" your collections to form a parent/child relationship. Otherwise you'll just be binding to flat collections. I recommend reviewing this stack overflow article. https://stackoverflow.com/questions/35791114/create-list-of-tuples-with-data-from-nested-lists-with-linq
If you were to use two datatables then you can use a dataset and use it's Relations property and add identifier ('ids') columns to join them together and create a hierarchy.
Let me know if you have any quesitons.
I am not sure if the tuples can be used directly ... it would be a plus if we could ... but my assumption is that I would have
to each into a BindingList...
which is what I did in this set..
// var userClaims = new BindingList<UserClaimViewDto>( msg.Item1 ); // var documents = new BindingList<DocumentViewDto>( msg.Item2); // var pages = new BindingList<DocumentPageViewDto>(msg.Item3);
It is the next (and I think last step) that is causing me problems... How Can I create the data relationshps between BindingLists? I would think this would be a simpler problem than trying to make the tuples work ... I am trying to get away from datasets ... I know how to build the relationships in datasets .. in fact you can see this in the original code I have .. I used DataRelations ... all good ... I have found something called DataRelationCollection but I don't think this is what I need ...
Bottom line... since datasets are not POCO ... how can I get ultragrid to work with POCO collections when setting up a master detail (and in this grandchild) ....
I am trying to do this all programatically ... in the past I have used devexpress and there I could introduce different dataviews via their designer to create one datagrid with nested dataviews .... but I don't see any support for this with infragistics ....
If you want to bind an UltraWinGrid to a BindingList that shows three levels of hierarchical data, then the objects at each level simply need to expose a property of type BindingList<T>. So in your example, the UserClaimViewDto class would need to expose a property of type BindingList<DocumentViewDto>. It must be a property, not a member, and it must never return null - although it can return an empty BindingList. And to display a third level, the DocumentViewDto class would need to likewise have a property that returns a BindingList<DocumentPageViewDto>.The data structure of the grid is built from the data source. And you can't assign a data source at each level, there's only one. So when the grid and the DotNet BindingManager examine the structure of the root-level data, it looks for properties that are lists and dislpays those as child bands, instead of as a column.
Thank you ... That worked !!!!
opps .. I there was a problem with the accept answer , but Mike did supply the answer