I am displaying a 2-level data on xamDataGrid and record selector has been replaced with checkbox. anyway to increase the indent of child level.
Hello,
You can create a style for the DataRecordPresenter and set the Left Margin. If you don't set a x:key of the style, it will be applied to all of the DataRecordPresenter including the parent Records, and the there will be a margin as well. If you do set x:key, you have to apply this style to the records you choose ( child records ).
<Style TargetType="{x:Type igDP:DataRecordPresenter}" BasedOn="{x:Null}">
<Setter Property="Margin" Value="20,0,0,0"/>
</Style>
Alex.
Alex,
I tried your way but seems like it doesn't work...I attached my codes. can u pls take a look.
Thanks a lot.
<igDP:XamDataGrid Grid.Row="1" x:Name="xamDataGrid" Theme="Aero" AutoFit="False" ContextMenu="{x:Null}" SnapsToDevicePixels="True" ScrollingMode="Immediate" AllowDrop="True" RecordContainerGenerationMode="Recycle" CellContainerGenerationMode="Recycle" RecordLoadMode="LoadOnDemand" Background="Gray" DragOver="OnDragOver" Drop="OnDataDrop" PreviewMouseDown="OnXamDataGridPreviewMouseDown" PreviewMouseMove="OnXamDataGridPreviewMouseMove" PreviewMouseUp="OnXamDataGridPreviewMouseUp" MouseDoubleClick="OnGridMouseDoubleClick" MouseRightButtonDown="OnGridMouseRightButtonDown" IsGroupByAreaExpanded="False"> <igDP:XamDataGrid.Resources> <Style TargetType="{x:Type igDP:RecordSelector}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:RecordSelector}"> <CheckBox HorizontalAlignment="Center" VerticalAlignment="Center" IsChecked="{Binding Path=DataItem.IsChecked}" Checked="OnChecked" Unchecked="OnUnChecked" > </CheckBox> </ControlTemplate> </Setter.Value> </Setter> </Style> <Style TargetType="{x:Type igDP:DataRecordPresenter}"> <Setter Property="Margin" Value="80,0,0,0"/> </Style> </igDP:XamDataGrid.Resources> <igDP:XamDataGrid.FieldLayoutSettings> <igDP:FieldLayoutSettings DataRecordSizingMode="SizedToContentAndIndividuallySizable" AutoGenerateFields="True" RecordSelectorLocation="LeftOfCellArea" ResizingMode="Default" SelectionTypeRecord="Extended" SelectionTypeField="Extended" DataRecordPresenterStyle="{StaticResource headerStyle}" DataRecordCellAreaStyle="{StaticResource rowStyle}" SelectionTypeCell="Extended"/> </igDP:XamDataGrid.FieldLayoutSettings> <igDP:XamDataGrid.FieldSettings> <igDP:FieldSettings AllowEdit="False" CellClickAction="SelectRecord" CellMinWidth="0" AllowCellVirtualization="true" CellValuePresenterStyle="{StaticResource cellStyle}" LabelPresenterStyle="{StaticResource columnStyle}"/> <!--CellValuePresenterStyle="{StaticResource cellStyle}"--> </igDP:XamDataGrid.FieldSettings> </igDP:XamDataGrid>
That is because you have two styles for the DataRecordPresenter. WPF supports only one local style. You have to merge the following into one single style:
DataRecordPresenterStyle="{StaticResource headerStyle}" and
<Style TargetType="{x:Type igDP:DataRecordPresenter}"> <Setter Property="Margin" Value="80,0,0,0"/> </Style>
You saved my life again :)
My boss keeps asking more.....I followed your suggestion and xmldatagrid looks like below. Now he doesn't like the increased indent push right the whole row. In other words we wanna all columns of child row,except the first column (TMS trade id), should be aligned with the ones of parent row. Is there a way to archive this?
Thanks
Hi,
I am going to propose a better solution to your first question. It is better to place that setter in a trigger and set the margin only to the records that are child, not the parent ( as the whole grid looks like is moved to the right ) so the style should look like this:
<Style.Triggers>
<Trigger Property="HasChildData" Value="False">
<Setter Property="Margin" Value="80,0,0,0"/>
</Trigger>
</Style.Triggers>
About your next question, It would not be an easy task to do this especially if the user can move the fields and resize them. If you have defined the FieldLayouts in the xaml, you can adjust their width so that the columns line up. If the fields can be moved and resized, accomplishing this task would require more manual code.
tried both but still no luck.....I ended up change margin of recordselector in code.
Try changing both like CellWidht and LabelWidth
Note: make sure you have defined the fields and CellWidth and LabelWidth in the xaml, otherwise these numbers will be NaN and nothing will happen.
also tried cellwidth...no luck...guess the way i set width of cell is wrong?
I wrote handler as below...But it doesn't work...any idea?
void OnInitializeRecord(object sender, Infragistics.Windows.DataPresenter.Events.InitializeRecordEventArgs e) { DataRecord dr = e.Record as DataRecord; if (dr != null && dr.ParentRecord != null) dr.Cells[0].Field.Settings.LabelWidth = dr.Cells[0].Field.Settings.LabelWidth - 20; }
If you will not be changing this cell's width, you can set it in the XAML. If you need to change it in runtime, you can use InitializeRecord event.