Hello,
I have a XamDataGrid with a list of equipments, and I need to set a range of columns with DateTime in header (based on a period set by user filter) and a mark on equipment row below the date when the equipment broke down. In my ViewModel I have a collection with the selected dates, and a list of equipments, each one contains a list of string (blanck or 'x') of same size than my list of dates.
I would like to do like this: Sample with datagrid , but I have not yet found how to implement that with XamDataGrid. I prefer not to use code behind.
Any ideas ?
Patrick
current XamDataGrid:
<igDP:XamDataGrid x:Name="DefectSynthesisDataGrid" Grid.Row="0" DataSource="{Binding MatchedDefectsSynthesis}" Margin="2,0,2,2"> <igDP:XamDataGrid.FieldSettings> <igDP:FieldSettings Width="Auto" AllowEdit="False" AllowRecordFiltering="True" CellClickAction="SelectRecord" SummaryDisplayArea="BottomFixed" /> </igDP:XamDataGrid.FieldSettings> <igDP:XamDataGrid.FieldLayoutSettings> <igDP:FieldLayoutSettings CopyFieldLabelsToClipboard="True" AllowAddNew="False" AllowDelete="False" AllowFieldMoving="Yes" AllowRecordFixing="No" AutoGenerateFields="False" AllowClipboardOperations="Copy" HeaderPrefixAreaDisplayMode="FieldChooserButton" SelectionTypeRecord="Extended" ExpansionIndicatorDisplayMode="Default" /> </igDP:XamDataGrid.FieldLayoutSettings> <igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout> <igDP:UnboundField Name="MeterId" Column="3" Width="Auto" BindingPath="Meter.MeterId.DataValue" Label="N° de l'équipement" FixedLocation="FixedToNearEdge"/> <igDP:UnboundField Name="MeterName" Column="4" Width="Auto" BindingPath="Meter.MeterName.DataValue" Label="Libellé de l'équipement" FixedLocation="FixedToNearEdge"/> <igDP:UnboundField Name="MeterType" Column="5" Width="Auto" BindingPath="Meter.MeterType.DisplayLabel" Label="Type" FixedLocation="FixedToNearEdge"/> <igDP:UnboundField Name="EmergencyLevel" Column="6" Width="Auto" BindingPath="UserDefectMeter.EmergencyLevel.DataValue" Label="Urgence" Converter="{StaticResource EmergencyTypeToDisplayNameConverter}" FixedLocation="FixedToNearEdge"/> <igDP:UnboundField Name="DefectCode" Column="7" Width="Auto" BindingPath="UserDefectMeter.DefectMeter.DefectCode" Label="Code défaut" FixedLocation="FixedToNearEdge"/> <igDP:UnboundField Name="DefectName" Column="8" Width="Auto" BindingPath="UserDefectMeter.DefectMeter.DefectLabel" Label="Libellé du défaut" FixedLocation="FixedToNearEdge"/> <igDP:UnboundField> <igDP:UnboundField.Settings> <igDP:FieldSettings> <igDP:FieldSettings.CellValuePresenterStyle> <Style TargetType="{x:Type igDP:CellValuePresenter}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <ItemsControl ItemsSource="{Binding DefectMeterByDay}"> <ItemsControl.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding }" /> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> </ControlTemplate> </Setter.Value> </Setter> </Style> </igDP:FieldSettings.CellValuePresenterStyle> <igDP:FieldSettings.LabelPresenterStyle> <Style TargetType="{x:Type igDP:LabelPresenter}" BasedOn="{x:Static igThemes:DataPresenterOnyx.LabelPresenter}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:LabelPresenter}"> <ItemsControl ItemsSource="{Binding MatchedDefectsSynthesis, Path=DaysInPeriod}"> <ItemsControl.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding self, Path=Day}" TextAlignment="Center"/> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> </ControlTemplate> </Setter.Value> </Setter> </Style> </igDP:FieldSettings.LabelPresenterStyle> </igDP:FieldSettings> </igDP:UnboundField.Settings> </igDP:UnboundField> <igDP:UnboundField Name="DefectMeterNbOccurences" Width="Auto" BindingPath="DefectMeterNbOccurences" Label="Total" FixedLocation="FixedToFarEdge"/> </igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts> </igDP:XamDataGrid>
Thank you for your post. I have been looking into it and the code you have provided and I suggest you use the following UnboundField instead of the one you have bolded in you post:
<igDP:UnboundField > <igDP:UnboundField.Settings> <igDP:FieldSettings> <igDP:FieldSettings.CellValuePresenterStyle> <Style TargetType="{x:Type igDP:CellValuePresenter}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <ItemsControl ItemsSource="{Binding Path=DataItem.DefectMeterByDay}"> <ItemsControl.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding}" /> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> </ControlTemplate> </Setter.Value> </Setter> </Style> </igDP:FieldSettings.CellValuePresenterStyle> <igDP:FieldSettings.LabelPresenterStyle> <Style TargetType="{x:Type igDP:LabelPresenter}" BasedOn="{x:Static igThemes:DataPresenterOnyx.LabelPresenter}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:LabelPresenter}"> <ItemsControl ItemsSource="{Binding RelativeSource={RelativeSource AncestorType={x:Type igDP:XamDataGrid}},Path=DataContext.MatchedDefectsSynthesis.DaysInPeriod}"> <ItemsControl.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Day}" TextAlignment="Center"/> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> </ControlTemplate> </Setter.Value> </Setter> </Style> </igDP:FieldSettings.LabelPresenterStyle> </igDP:FieldSettings> </igDP:UnboundField.Settings> </igDP:UnboundField>
Also, since I cannot be completely sure how your data is organized, you may need to change LabelPresenterStyle’s ItemsSource’s Path of the Binding. Please let me know if this helps you, if not it would be great if you could send me an isolated sample project, so I can make the Bindings for you.
Looking forward for your reply.
Thanks for your help. Now I have something displayed, it's better than before. But all my crosses are in the same cell, and the header is empty. I made a sample with my XamDataGrid and my ViewModel.
Regards,
Hello Patrick,
I have been looking into your requirement and I modified the sample you sent me, so now the Header is not empty. Please let me know if this helps you, if not could you please send me a screenshot of the desired result, so I can investigate this further for you.
Hello Stefan,
Thanks for your support. Now all results are displayed in a single column, my purpose is to separate them by date, like that:
I hope it will help you to investigate.
Hello again,
I have been looking into your screenshot and I modified the sample I sent you before, so now it looks as you want. Please let me know if this helps you or you need further assistance.
Thank you very much for your support, now is exactly as I wanted.
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.