I am having trouble showing child rows when a datarecord has an expandable field. The grid will only show expandable fields and it does not show the childrows, however i can see the childrows and the expandable field getting assigned the correct fieldlayout in the OnAssigningFieldLayoutToItem method. I am binding a collection of Securable objects to the xamadatagrid, my class snippets are listed below.
public class secureable
{
public string Name {get;set;}
public string Description {get;set;}
//Expandable property
public List<Permission> Permissions {get;set;}
//Child rows
public List<Securable> Children{get; set;}
}
public class Permission
public string PermissionObject {set; get;}
public string PermissionRight {set; get;}
Hello Satu,
I have built a sample project using the data structure that you have provided and am auto-generating the Fields in the XamDataGrid at the moment, and I am able to see the child rows placed in the "Children" List<Securable> that you have provided. I am auto-generating the Fields at the moment, as I am not entirely sure I understand the behavior or structure that you are seeing or are hoping to see. At the moment, the behavior I am getting on my end is that each parent "Securable" record has two expandable field records for "Children" and "Permissions." After expanding each of these, I can see the associated Permission elements and the child Securable elements.
I am attaching the sample project I used to test this. Please run this on your machine. If this sample project is not an accurate depiction of what you are trying to do, please feel free to modify it and send it back such that it is. Alternatively, if you have an isolated sample project of your own that demonstrates the unexpected behavior that is happening on your end, I will gladly take a look if you attach it.
My tests were made against version 17.2.20172.1000 in Infragistics for WPF 2017 Volume 2.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate Developer
Hello Andrew,
Thanks for the example. Unfortunately this did not solve my problem. I am not using Auto-generated fields. I am creating my fields and field layouts dynamically because the securable object can use a variable number of properties. I adjusted your sample to closely resemble what I am trying to accomplish, and I was able to reproduce the behavior I am seeing, where it does not display the childrows of data at all, but I see the layout properly assigned in the XamDataGrid_OnAssigningFieldLayoutToItem event.
I am using version 16.2 in the sample application attached.
I have been investigating your sample project, and it appears that in your method that is creating your "Children" Field, you are marking the Field's Visibility as Hidden. This will hide the ExpandableFieldRecord. I would recommend that you remove this setting. By default, if a Field is pointed at a collection, it is determined to be a placeholder and the Field won't actually be shown. Instead, the grid will interpret it as a pointer for a hierarchy, and marking this Field hidden will remove that hierarchy.
I have attached a modified version of your sample project to demonstrate. I hope this helps.
I appreciate your reply. This does get me closer to a solution, but not quite there. Is it possible to show the children rows directly underneath the Expandable property like the attached image?
Being that your data item contains two collections, it is not currently possible to not show the ExpandableFieldRecord if you are looking to have bands for both of those children. It is, however, possible to "fake" this.
I would recommend that you write a Style for ExpandableFieldRecordPresenter and use a DataTrigger to bind to "Field.Name." Here, you can check for the ExpandableFieldRecord representing the collection that you do not wish to show the ExpandableFieldRecord for, but wish to show the records directly under the parent band. In this case, it would be "Children." If the condition matches, you can set the Height of the ExpandableFieldRecordPresenter to zero in order to prevent it from being shown, but still allow it to be part of the visual tree.
Working with this, I would recommend that you handle the RecordExpanded event of the XamDataGrid. In doing so, you can catch when a particular DataRecord expands, and programmatically expand the corresponding ExpandableFieldRecord for your Children collection. You can get this ExpandableFieldRecord from the DataRecord.ChildRecords collection and you can expand it by setting its IsExpanded property.
I have attached a modified version of the previously attached sample project to demonstrate. I hope this helps.
That worked perfectly!!! Thanks for all your help.