Hi!
This maybe a misunderstanding by a newbie, but I thought with setting AutoGenerateFields="False" only fields would show up I explicity defined. However in the example below I also get a column "email".
Am I missing the point here?
<igDP:XamDataGrid x:Name="XamDataGrid1" BindToSampleData="true" > <igDP:XamDataGrid.FieldLayoutSettings> <igDP:FieldLayoutSettings AutoGenerateFields="False" /> </igDP:XamDataGrid.FieldLayoutSettings> <igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout> <igDP:FieldLayout.Fields> <igDP:Field Name="name" Label="f1" /> <igDP:Field Name="department" Label="f2" /> <igDP:Field Name="salary" Label="f3" /> </igDP:FieldLayout.Fields> </igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts> </igDP:XamDataGrid>
Finally I figured out my problem. The Name of Field is very case sensitive. ProjectCode should be projectCode. This was making me crazy for whole day.
Finally got out of it.
I'm not able to show my custom fields on the xamDataGrid. If AutoGenerateFeilds=true then the whole DataSet is showed on the screen, but when set to false, then none is showed.
<igDP:XamDataGrid x:Name="xamGrid" BindToSampleData="False" > <igDP:XamDataGrid.FieldLayoutSettings> <igDP:FieldLayoutSettings AutoGenerateFields="False"/> </igDP:XamDataGrid.FieldLayoutSettings>
<igDP:XamDataGrid.FieldSettings> <igDP:FieldSettings AllowEdit="False" />
</igDP:XamDataGrid.FieldSettings>
<igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout> <igDP:Field Name="ProjectCode" Visibility="Visible"/> </igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts> </igDP:XamDataGrid>
(ProjectCode matches the column in the dataset.)
Data is being filled in DataSource from DataSet but still a blank datagrid is being shown.
xamGrid.DataSource=ds.Tables[0].DefaultView;
Couldn't figure out the problem.
Please help!!!
Thanks and Regards,
Varun Jain
Hi Martin,
The reason this happens is because the FieldLayout matching logic can't find a match and generates a new fieldlayout. However, if you set the AutoGenerateFields property of the XamDataGrid's FieldLayoutSettings (which becomes the default for all FieldLayouts) then you would see the expected behaviour, i.e. no fields would be shown: e.g.
<igDP:XamDataGrid.FieldLayoutSettings> <igDP:FieldLayoutSettings AutoGenerateFields="False" /> </igDP:XamDataGrid.FieldLayoutSettings>
In the example you gave you set the AutoGenerateFields propery on the specific FieldLayou you defined in Xaml which wasn't used due to the field name not matching.
Joe
I have found that if a field Name does not exits, instead of ignoring it as is the WPF default the xamDataGrid will ignore the AutoGeneratteFields=False and display all of the fields.
This may be as designed behaviour, but it is most anoying...
I too am having this problem:
<igDP:XamDataGrid DataSource="{Binding AvailableProjects}" AutoFit="True" Name="XamDataGrid1" GroupByAreaLocation="None">
<igDP:XamDataGrid.Resources>
<!-- This Style puts a CheckBox into the record selectors. -->
<Style TargetType="{x:Type igDP:RecordSelector}" BasedOn="{x:Null}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igDP:RecordSelector}">
HorizontalAlignment="Center"
VerticalAlignment="Center"
IsChecked="{Binding Path=DataItem.IsChecked, Mode=TwoWay}"
/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- This Style puts a CheckBox into the header area above the record selectors. -->
<Style TargetType="{x:Type igDP:HeaderPrefixArea}" BasedOn="{x:Null}">
<Setter Property="Visibility" Value="Visible" />
<ControlTemplate TargetType="{x:Type igDP:HeaderPrefixArea}">
<CheckBox
IsChecked="{Binding Path=DataPresenter.DataContext.AllMembersAreChecked, Mode=TwoWay}"
</igDP:XamDataGrid.Resources>
<igDP:XamDataGrid.FieldSettings>
<igDP:FieldSettings AllowEdit="False" GroupByMode="Default"/>
<igDP:XamDataGrid.FieldLayouts>
<igDP:FieldLayout>
<igDP:FieldLayout.Settings>
<igDP:FieldLayoutSettings AutoArrangeCells="Never" AutoGenerateFields="False" />
</igDP:FieldLayout.Settings>
<igDP:FieldLayout.Fields>
<igDP:Field Name="Name" Label="Server Name" />
<igDP:Field Name="IsChecked" Visibility="Collapsed" />
</igDP:FieldLayout.Fields>
<igDP:FieldLayout.SortedFields>
<igDP:FieldSortDescription FieldName="Name" />
</igDP:FieldLayout.SortedFields>
</igDP:FieldLayout>
</igDP:XamDataGrid.FieldLayouts>
</igDP:XamDataGrid>
Even though I have the AutoGenerate set to false, I see all the fields from my data, even down to Hierarchical items...