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>
Actually we special case it when BindToSampleData is set to True to always auto generate fields. The reason for this is because this property was intended for use mainly at design time to allow you to see what the grid would look like with some random data in it. If you were working on a app where the AutoGenerateFields was set to false then you wouldn't see anything and BindToSampleData would be useless.
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.FieldSettings>
<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...
"The reason this happens is because the FieldLayout matching logic can't find a match and generates a new fieldlayout."
Is there any way to find out WHY a match cannot be found? I get this behavior seemingly randomly and cannot figure out why this is sometimes happening (sometimes it happens sometimes not when running the application and showing different instances of the same grid).
No exceptions, no errors, no warnings. Very difficult to debug!
Make sure all of the Names of all of the Fields you do specify match property names or column names of your data source exactly (case-sensitive). Otherwise, the FieldLayout you specified won't match and we will generate one that does, in this case without any fields since AutoGenerateFields is false.
I am facing an issue with the FieldLayoutSettings. Initially, I was getting extra columns which I had not specified in the fieldlayout. After reading the suggestions above, I moved the fieldlayout settings and made it global, for a xamdatagrid. But now, I am not able to see anything on the grid. I am new to infragistics and would really appreciate any help in this regard.
<igDP:XamDataGrid DataSource="{Binding List}" VerticalAlignment ="Top" Background ="Gray" Theme
="Office2k7Black" >
<igDP:XamDataGrid.FieldLayoutSettings
>
<igDP:FieldLayoutSettings AutoGenerateFields
="False" />
</igDP:XamDataGrid.FieldLayoutSettings
<igDP:XamDataGrid.FieldSettings
<igDP:FieldSettings AllowEdit="False" LabelPresenterStyle="{Binding Source={StaticResource Epro36HeaderFont
}}"/>
</igDP:XamDataGrid.FieldSettings
<igDP:XamDataGrid.FieldLayouts
<igDP:FieldLayout
<igDP:FieldLayout.Fields
<igDP:Field Width="auto" Label="{Binding ComponentName}" Name
="Pnl">
<igDP:Field.Settings
<igDP:FieldSettings CellValuePresenterStyle ="{StaticResource XamCellValuePresenter}" EditorType="{x:Type Editors:XamNumericEditor}" EditorStyle="{StaticResource XamNumEditorStyle
}">
</igDP:FieldSettings
</igDP:Field.Settings
</igDP:Field
<igDP:Field Width="auto" Label="{Binding YestUSD}" Name
="YestUSD" >
<igDP:Field Width="auto" Label="{Binding TodayUSD}" Name
="TodayUSD" >
<igDP:Field Width="auto" Label="{Binding Total}" Name
="Total" >
</igDP:FieldLayout.Fields
</igDP:FieldLayout
</igDP:XamDataGrid.FieldLayouts
</igDP:XamDataGrid
-->Hi,
Thanks for this tip, I too was struggling with no fields being displayed, It turns out that if ANY of your fields don't match the data source then NO fields will be displayed and you get the blank grid.