Hello,
i've a little problem. I built a XamDataGrid with a XamDataPresenter. (example at the end of this post)
My first problem: I created about 10 different FieldLayouts. In my dataGrid I want to show only one GridHeader at the Top of the DataGrid. I tried to do much with the LabelLocation and Headerplacement in the FieldlayoutSettings and the Settings Of each FieldLayout seperately, but either there's shown no Header or a seperete Header on top of a group of records which have the same FieldLayout. (like here: http://forums.infragistics.com/forums/p/43282/300445.aspx#300445)
I only got:
Record1: FieldLayout1Record2: FieldLayout1Header from FieldLayout2Record3: FieldLayout2Record4: FieldLayout2Record5: FieldLayout1Record6: FieldLayout1Header from FieldLayout2Record7: FieldLayout2 Record8: FieldLayout2
but i want it to look like this:
Header from FieldLayout2Record1: FieldLayout1 Record2: FieldLayout1 Record3: FieldLayout2 Record4: FieldLayout2 Record5: FieldLayout1 Record6: FieldLayout1 Record7: FieldLayout2 Record8: FieldLayout2
Or better would be a Header from a FieldLayout which isn't used at any row in the grid.
I also tried to do something with UnboundFields, which are inserted above the Header Row like in an example called "XDG_Complex_Spreadheader" i also got it from this forum but can't find the post anymore. But i didn't get it to look like a standard-looking header.
---------
Another Qestion: I have often very similar Fields in every FieldLayout. For example this Field:
<igDP:Field Name="Bez" Width="125"> <igDP:Field.Settings> <igDP:FieldSettings AllowEdit="False" /> </igDP:Field.Settings> </igDP:Field>
It's the same in every Layout. Can i simplify this in any way in xaml. Or should i use the code-behind-way to create the Field Layouts?
Thank you very much for every help i get! If you need more infos, no problem, tell me.
Jochen
Here's some example code: (I shortened it a bit) ;)
<igDP:XamDataPresenter Margin="0" Name="spd" CellContainerGenerationMode="PreLoad"> <!-- VIEW --> <igDP:XamDataPresenter.View> <igDP:GridView> <igDP:GridView.ViewSettings> <igDP:GridViewSettings UseNestedPanels="True" Orientation="Vertical" /> </igDP:GridView.ViewSettings> </igDP:GridView> </igDP:XamDataPresenter.View> <!-- RESOURCES --> <igDP:XamDataPresenter.Resources> <Style x:Key="RoundingStyle" TargetType="{x:Type igEditors:XamNumericEditor}"> <Setter Property="Mask" Value="n.nnn"/> </Style> <Style x:Key="CheckStyle" TargetType="{x:Type igEditors:XamCheckEditor}"> <EventSetter Event="ValueChanged" Handler="cValueChanged"/> </Style> <igEditors:ComboBoxItemsProvider x:Key="TabAlignItemsProvider" /> <Style x:Key="TabAlignFieldStyle" TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsProvider" Value="{StaticResource TabAlignItemsProvider}" /> </Style> <igEditors:ComboBoxItemsProvider x:Key="TabGeItemsProvider" /> <Style x:Key="TabGeFieldStyle" TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsProvider" Value="{StaticResource TabGeItemsProvider}" /> </Style>
<igEditors:ComboBoxItemsProvider x:Key="EinhLenItemsProvider" /> <Style x:Key="EinhLenFieldStyle" TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsProvider" Value="{StaticResource EinhLenItemsProvider}" /> </Style> </igDP:XamDataPresenter.Resources> <!-- FIELDLAYOUT SETTINGS --> <igDP:XamDataPresenter.FieldLayoutSettings> <igDP:FieldLayoutSettings AutoGenerateFields="False" AllowFieldMoving="No" LabelLocation="Hidden" SelectionTypeCell="Single" SelectionTypeField="None" SelectionTypeRecord="Single"/> <!--AutoArrangeCells="Never"--> </igDP:XamDataPresenter.FieldLayoutSettings> <!-- FIELD SETTINGS --> <igDP:XamDataPresenter.FieldSettings> <igDP:FieldSettings AllowResize="False" /> </igDP:XamDataPresenter.FieldSettings> <!-- FIELD LAYOUTS --> <igDP:XamDataPresenter.FieldLayouts> <igDP:FieldLayout Key="LayoutGebEl"> <igDP:FieldLayout.Fields> <igDP:Field Name="Bez" Width="125"> <igDP:Field.Settings> <igDP:FieldSettings AllowEdit="False" /> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="Cap" Width="95" /> <igDP:Field Name="Rank" Width="30" /> <igDP:Field Name="Einh" Width="120"> <igDP:Field.Settings> <igDP:FieldSettings EditorType="{x:Type igEditors:XamComboEditor}"> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsProvider" Value="{StaticResource TabGeItemsProvider}" /> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="TabW" Width="30" /> <igDP:Field Name="TabT" Width="100"> <igDP:Field.Settings> <igDP:FieldSettings EditorType="{x:Type igEditors:XamComboEditor}"> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsProvider" Value="{StaticResource TabAlignItemsProvider}" /> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="Z" Width="Auto" Row="1" Column="6"> <igDP:Field.Settings> <igDP:FieldSettings EditorStyle="{StaticResource CheckStyle}" /> </igDP:Field.Settings> </igDP:Field> <!--<igDP:UnboundField Name="HeaderLabel" Label="HeaderLabel" Row="0" Column="2"> <igDP:UnboundField.Settings> <igDP:FieldSettings CellValuePresenterStyle="{StaticResource NoDataCellValuePresenter}" LabelPresenterStyle="{StaticResource LabelHeaderLabelPresenter}"/> </igDP:UnboundField.Settings> </igDP:UnboundField>--> </igDP:FieldLayout.Fields> </igDP:FieldLayout> <igDP:FieldLayout Key="LayoutGroupable"> <igDP:FieldLayout.Fields> <igDP:Field Name="Bez" Width="125"> <igDP:Field.Settings> <igDP:FieldSettings AllowEdit="False" /> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="Cap" Width="95" /> <igDP:Field Name="Rank" Width="30" /> <igDP:Field Name="Rundung" Width="120"> <igDP:Field.Settings> <igDP:FieldSettings AllowEdit="False" /> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="TabW" Width="30" /> <igDP:Field Name="TabT" Width="100"> <igDP:Field.Settings> <igDP:FieldSettings EditorType="{x:Type igEditors:XamComboEditor}"> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsProvider" Value="{StaticResource TabAlignItemsProvider}" /> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="Z" Width="Auto"> <igDP:Field.Settings> <igDP:FieldSettings EditorStyle="{StaticResource CheckStyle}" /> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="G" Width="Auto" /> </igDP:FieldLayout.Fields> </igDP:FieldLayout> <igDP:FieldLayout Key="LayoutDimLength"> <igDP:FieldLayout.Fields> <igDP:Field Name="Bez" Width="125"> <igDP:Field.Settings> <igDP:FieldSettings AllowEdit="False" /> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="Cap" Width="95" /> <igDP:Field Name="Rank" Width="30" /> <igDP:Field Name="Rundung" Width="55"> <igDP:Field.Settings> <igDP:FieldSettings EditorStyle="{StaticResource RoundingStyle}" /> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="Einh" Width="65"> <igDP:Field.Settings> <igDP:FieldSettings EditorType="{x:Type igEditors:XamComboEditor}"> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsProvider" Value="{StaticResource EinhLenItemsProvider}" /> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="TabW" Width="30" /> <igDP:Field Name="TabT" Width="100"> <igDP:Field.Settings> <igDP:FieldSettings EditorType="{x:Type igEditors:XamComboEditor}"> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsProvider" Value="{StaticResource TabAlignItemsProvider}" /> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="Z" Width="Auto"> <igDP:Field.Settings> <igDP:FieldSettings EditorStyle="{StaticResource CheckStyle}" /> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="G" Width="Auto" /> </igDP:FieldLayout.Fields> </igDP:FieldLayout> <igDP:FieldLayout Key="LayoutElse"> <igDP:FieldLayout.Fields> <igDP:Field Name="Bez" Width="125"> <igDP:Field.Settings> <igDP:FieldSettings AllowEdit="False" /> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="Cap" Width="95" /> <igDP:Field Name="Rank" Width="30" /> <igDP:Field Name="Rundung" Width="120"> <igDP:Field.Settings> <igDP:FieldSettings AllowEdit="False" /> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="TabW" Width="30" /> <igDP:Field Name="TabT" Width="100"> <igDP:Field.Settings> <igDP:FieldSettings EditorType="{x:Type igEditors:XamComboEditor}"> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsProvider" Value="{StaticResource TabAlignItemsProvider}" /> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="Z" Width="Auto"> <igDP:Field.Settings> <igDP:FieldSettings EditorStyle="{StaticResource CheckStyle}" /> </igDP:Field.Settings> </igDP:Field> </igDP:FieldLayout.Fields> </igDP:FieldLayout> </igDP:XamDataPresenter.FieldLayouts>
Hello Stefan,
thanks for the example. I understood it good. I also had a similar idea like an Master Layout. But there is a big problem. I fill the datagrid dynamically. It could be that the first record needs layout1 oder it could be that layout2 is needed.
You probably would say, then make 2 Master Layouts. But this was only the example. In real i have 10 FieldLayouts!! And Everyone could be the first. I think it's not wise to copy the 10 Layouts and make 10 Masterlayouts. This is very much code and more problematic is if i want to change a field or something else in a layout, i always have to look that i also change the master layout.
I changed my first example a bit. Now the Fields are created randomly and also the fieldlayouts are assigned randomly. This should simulate my situation more exactly.
Important for me is: The Header should always look like FieldLayout2 (see example) even if the firstRecord has another FieldLayout!!!
Header look that i always need in my example:
I hope you can find a solution for this problem, too.
Hello Jochen,
I have been looking into your sample and I modified it, so now it works as you want. Basically I created a FieldLayout without a Key which looks like your FieldLayout2 and it is applied to the first item in the AssignFieldLayoutToItem event. Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.
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.
Hi Stefan,
Thank You very much for the hints, they were very heplful.
I solved all problems i had.
Sincerely,
I have been looking into your requirements and I believe your best option is to use super headers as it is described in this forum thread:
http://community.infragistics.com/forums/p/50873/276186.aspx
Also for the border you want, you can create a Style for the DataRecordCellArea and set its BorderThickness like this:
<Style TargetType="{x:Type igDP:DataRecordCellArea}"> <Setter Property="BorderThickness" Value="0,0,0,2"/> <Setter Property="BorderBrush" Value="Red"/> <Setter Property="CornerRadius" Value="0"/> </Style>
Please let me know if this helps you or you need further assistance on this matter.
Thank you for the new example. It's not exactly what i expected, but i can almost solve my problem now.
I think, what i miss is more flexibility to the Spread Header! I want the Header look a bit different than it sould be.
Is it possible to merge two header fields, or to split a header field WITHOUT making changes on the fields that rely to it? If yes, how?
--------------------------------------
Another Question that i have:
Is it possible to draw a line (e.g. 2px thickness) between 2 Records/Rows in the DataGrid?
Thanks very much,