Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
985
Select Specific columns from Datasource
posted

Hello Infragistics team,

My xamdatagrid is bound to an ienumerable observable collection. I want to show only specific columns from the collection. I am unable able to do this, when I include a checkbox column in the xamdatagrid. Below is my xaml code:

<igWPF:XamDataGrid IsGroupByAreaExpanded="False" GroupByAreaLocation="None" HorizontalAlignment="Left" Margin="21,96,0,0" Name="xamDataGrid1" VerticalAlignment="Top" Height="271" Width="453"
DataSource="{Binding Disciplines}"
Theme="IGTheme"
>
<igWPF:XamDataGrid.Resources>
<!-- This Style puts a CheckBox into the record selectors. -->
<Style TargetType="{x:Type igWPF:RecordSelector}"
BasedOn="{x:Null}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igWPF:RecordSelector}">
<CheckBox 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 igWPF:HeaderPrefixArea}"
BasedOn="{x:Null}">
<Setter Property="Visibility"
Value="Visible" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igWPF:HeaderPrefixArea}">
<CheckBox HorizontalAlignment="Center"
VerticalAlignment="Center"
IsChecked="{Binding Path=DataPresenter.DataContext.AllMembersAreChecked, Mode=TwoWay}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</igWPF:XamDataGrid.Resources>
<!--#BEGIN SNIPPET#-->

<igWPF:XamDataGrid.FieldLayouts>
<igWPF:FieldLayout>
<igWPF:FieldLayout.Fields>
<igWPF:Field Name="G4_DI_Desc" Label="Disciplines" />
<igWPF:Field Name="G4_DI_Code" Label="Code" />
<igWPF:Field Name="IsChecked" Visibility="Collapsed" />
</igWPF:FieldLayout.Fields>
</igWPF:FieldLayout>
</igWPF:XamDataGrid.FieldLayouts>
<!--#END SNIPPET#-->
</igWPF:XamDataGrid>

I only want to include these two columns: G4_DI_Desc & G4_DI_Code in addition to the checkboxes column. How to achieve this?

Thank you

Parents
No Data
Reply
  • 30945
    Offline posted

    Hello Sherif,

     

    Thank you for your post. I have been looking into it and if I understand correctly, you wish to show only  G4_DI_Desc and G4_DI_Code fields and also to show the RecordSelectors and the HeaderPrefixArea with CheckBoxes. If this is correct, and you have more properties in your data source , which you wish to not be shown, I can suggest setting the AutoGeneratedFields property of the FieldLayoutSettings of  the XamDataGrid to false. By doing so, you will see only the Fields that are defined in the FieldLayouts of the XamDataGrid. You can read more detailed information regarding the how you can define FieldLayouts at the following blog post: http://ko.infragistics.com/community/blogs/petar_monov/archive/2011/05/13/how-to-define-fieldlayouts-how-fieldlyouts-are-mapped.aspx. I have also created  sample application for you, based on your code snippet, that shows how you can implement this approach.

     

     

     Please let me know if you need any further assistance on the matter.

     

    Sincerely,

    Krasimir

    Developer Support Engineer

    Infragistics

    www.infragistics.com/support

    ShowSpecificFields.zip
Children