Hi there
I was looking for a way to set the initial value of an unbound boolean field that is being displayed as a null value (I'd rather have it unchecked). As I didn't find a DefaultValue property or anything like it, I checked the archived forum for a solution and found this posting here:
http://tinyurl.com/23d467
It provides a solution using an EditorStyle and a feedback from Infragistics that a related bug was going to be fixed within the next few weeks. The posting is eight months old, but I am having the exact same problem. Is this issue back in 7.2 Beta or there is a mistake on my side?
<igDP:UnboundField Name="Checked" Label="" DataType="{x:Type sys:Boolean}"> <igDP:UnboundField.Settings> <igDP:FieldSettings AllowEdit="True" EditorType="{x:Type igEditors:XamCheckEditor}"> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamCheckEditor}"> <Setter Property="IsChecked" Value="False" /> <Setter Property="IsThreeState" Value="False" /> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:UnboundField.Settings></igDP:UnboundField>
...and this is how the above sample is being displayed:
Btw: The screenshot above also illustrates that the FieldLayoutSettings.DataRecordCellAreaGridTemplate seems to be buggy as well. I set up the grid with the following template:
<ItemsPanelTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="30" /> <ColumnDefinition Width="60" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> </Grid> </ItemsPanelTemplate>
As you can clearly see, the last column in NOT properly resized. I cheated a little with the screenshot (the text was cut just after Language), but the result is the same.
Thanks for your advice
Philipp
Hi Philipp,
The correct way to do this would be to hook into the InitializeRecord and set the initial value of the field there. Setting the default value in the style of the editor will not work because the editor will always display the underlying cell value, essentially ignoring what you set the IsChecked to in its style.
Sandip
Hello Sandip
That's how I did it - thanks for the explanation!
However, as a note for future releases - wouldn't it make sense to be able to set a default value for unbound fields? I'm sure this is quite a common scenario...
Cheers,