I have defined the columns of my XamDataGrid using FieldSettings and FieldLayout. But the problem is, that the grid takes all the properties from the "inserted" objects and displays them as columns. This means, that I have to create a specific ViewModel-class for the DataGrid, which is a bit annoying.
The standard WPF DataGrid has an attribute called AutoGenerateColumns. Does the XamDataGrid have something like this? I can't find it...
Hello Christian,
Thank you for your post. I have been looking through it and I suggest you use AutoGenerateFields property of the FieldLayoutSettings object of the XamDataGrid. Please let me know if you need further clarifications on this matter.
Looking forward fort your reply.
Hello Stefan,
My XAML-code looks like this:
<igDP:XamDataGrid
x:Name="IgGridProjects"
DataSource="{Binding Projects2}"
ActiveDataItem="{Binding CurrentProjListItem}"
SelectedItemsChanged="IgGridProjects_SelectedItemsChanged"
AssigningFieldLayoutToItem="IgGridProjects_AssigningFieldLayoutToItem"
GroupByAreaLocation="None">
<igDP:XamDataGrid.FieldLayouts>
<igDP:FieldLayout Key="masterRow">
<igDP:Field Name="ShortName" Label="Short Name" />
<igDP:Field Name="Name" Label="Name" />
<igDP:Field Name="Owner" Label="Owner" />
</igDP:FieldLayout>
<igDP:FieldLayout Key="nestedRow">
<igDP:Field Name="VersCreateDate" Label="Created On" />
<igDP:Field Name="VersUpdateDate" Label="Updated On" />
</igDP:XamDataGrid.FieldLayouts>
</igDP:XamDataGrid>
Where should I place the XAML you provided?
Hello again,
You can set the AutoGenerateFields property of the nested FieldLayout to False and define the Fields that you want to be displayed.
Isn't that the same as my previous question?
What I want to do here, is to specify the collection from which the nested items should be taken.
For example I have a vmProject ViewModel-class, that I use in my XamDataGrid. This class has two public collections, "Versions" and "Notes". In the XamDataGrid I only want to display objects from "Versions" as child-elements of vmProject. As of now the Grid displays both collections!
I still want the AutoGenerateFields set to false so that I can specify the columns myself.
I apologize for the misunderstanding. I created a sample project for you with the functionality you want. My custom class has two collections, too and I define the FiledLayout, so that only one of them is shown. When you have hierarchical data you should define a Field with the name of the collection or if you have DataSet, with the relationship, when the AutoGenereateFields property is set to False.
Looking forward for your reply.
Hello Stefan
Some time ago you helped me with removing headers and indentation from child-elements in the XamDataGrid.
http://community.infragistics.com/forums/p/56968/297637.aspx#297637
After I added the code from the previous posts (AutoGenerateFields, collections), the "styling" for headers and indentation doesn't work!
Could you take a look at this issue?
Hello,
Could you please send me an isolated sample project, where you put the solutions together, so I can investigate this further for you.
I am glad I helped you resolve this. As for your question I suggest you use the AutoFitMode of the FieldLayoutSettings. You can read about it here:
http://help.infragistics.com/NetAdvantage/WPF/2011.1/CLR4.0/?page=InfragisticsWPF4.DataPresenter.v11.1~Infragistics.Windows.DataPresenter.AutoFitMode.html
Hope this helps you.
Thanks. That worked great!
Another question. Is it possible to set some kind of "auto-width" on one of the fields? For example, the Name-field would be dynamic, so that the grid "fills" the window..
In your case the records you show as children are not directly children, and they are from the child collection and this is why they don’t have indentation. If you want you can create a style for set the DataRecordPresenter and set its Margin Property. I modified your sample from the previous post and attached it.
Apparently the indentation of nested items is removed when setting AutoGenerateFields to false.
How can I keep the indentation but still define my own fields?
No need for that!
I discovered what my problem was. I had removed a piece of XAML that for obvious reasons shouldn't be removed...
Sorry for the inconvenience...