Hi,
Is sorting supported for a unbound columns?
In my case all the columns are unbound.
<igDP:XamDataGrid HorizontalAlignment="Stretch" WControls:XamDataGridBehavior.IsSynchronizedWithCurrentItem="True" RecordLoadMode="PreloadRecords" VerticalAlignment="Stretch" DataSource="{Binding Path=CollectionView}" Margin="0,0,0,0" Grid.Row="0" GroupByAreaLocation="None">
<igDP:XamDataGrid.FieldSettings>
<igDP:FieldSettings AllowEdit="True"/>
</igDP:XamDataGrid.FieldSettings>
<igDP:XamDataGrid.FieldLayoutSettings>
<igDP:FieldLayoutSettings AutoGenerateFields="False" AllowAddNew="False" AllowDelete="True" AddNewRecordLocation="OnTopFixed"/>
</igDP:XamDataGrid.FieldLayoutSettings>
<igDP:XamDataGrid.FieldLayouts>
<igDP:FieldLayout>
<igDP:FieldLayout.Fields>
<igDP:UnboundField Name="FirstName" Label="First Name">
<igDP:Field.Settings>
<igDP:FieldSettings EditorType="{x:Type igEditors:XamTextEditor}">
<igDP:FieldSettings.EditorStyle>
<Style TargetType="{x:Type igEditors:XamTextEditor}">
<Setter Property="Text" Value="{Binding Path=DataItem.FirstName,Mode=TwoWay,ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}"/>
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="true">
<Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors), Converter={StaticResource errorConverter}}"/>
</Trigger>
</Style.Triggers>
</Style>
</igDP:FieldSettings.EditorStyle>
</igDP:FieldSettings>
</igDP:Field.Settings>
</igDP:UnboundField>
<igDP:UnboundField Name="LastName" Label="Last Name">
<Setter Property="Text" Value="{Binding Path=DataItem.LastName,Mode=TwoWay,ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}"/>
<igDP:UnboundField Name="Gender" Label="Gender">
<igDP:FieldSettings EditorType="{x:Type igEditors:XamComboEditor}">
<Style TargetType="{x:Type igEditors:XamComboEditor}">
<Setter Property="DisplayMemberPath" Value="Name" />
<Setter Property="ValuePath" Value="GenderID"/>
<Setter Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}},Path=DataContext.Genders}" />
<Setter Property="Value" Value="{Binding Path=DataItem.Gender,Mode=TwoWay,ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}"/>
<igDP:UnboundField Name="Phone" Label="Phone">
<igDP:FieldSettings EditorType="{x:Type igEditors:XamMaskedEditor}">
<Style TargetType="{x:Type igEditors:XamMaskedEditor}">
<Setter Property="Mask" Value="(###)-###-####"/>
<Setter Property="Value" Value="{Binding Path=DataItem.Phone,Mode=TwoWay,ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}"/>
<igDP:UnboundField Name="DepartmentID" Label="Deparment ID">
<Setter Property="DisplayMemberPath" Value="DepartmentName" />
<Setter Property="ValuePath" Value="DepartmentID"/>
<Setter Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}},Path=DataContext.Departments}" />
<Setter Property="Value" Value="{Binding Path=DataItem.DepartmentID,Mode=TwoWay,ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}"/>
</igDP:FieldLayout.Fields>
</igDP:FieldLayout>
</igDP:XamDataGrid.FieldLayouts>
</igDP:XamDataGrid>
Thanks,
R.Ramesh Babu.
In order to enable sorting you need to set the "LabelClickAction" property of a FieldSettings object to a value allowing sorting.
For more detailed information on sorting, please refer to the following article:
http://help.infragistics.com/Help/NetAdvantage/WPF/2010.3/CLR4.0/html/xamDataPresenter_About_Sorting.html
Hope this helps.
the manual sorting works. But I want that the table is automatically sorted already during loading by the 2. Column (unbound) alphabetically.
Hi Djumana,
In this case I believe the following topic would be useful:
http://help.infragistics.com/NetAdvantage/WPF/2010.3/CLR4.0/?page=xamDataPresenter_Programmatically_Sort_and_Group_Fields.html
Hello,
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.
Wow, such a simple thing. But yes, it works, thank you!
And just for anyone else looking at this, to do a "multi-binding", try:
<igDP:UnboundField Label="DataLabel" Width="32"> <igDP:UnboundField.Binding> <MultiBinding Converter="{StaticResource ABtoValueConverter}"> <Binding Path="PropA" /> <Binding Path="PropB" /> </MultiBinding> </igDP:UnboundField.Binding> <igDP:UnboundField.Settings> <igDP:FieldSettings SortComparer="{StaticResource ABComparer}"/> </igDP:UnboundField.Settings> </igDP:UnboundField>
Hello Ryan,
I have been looking into your sample and I modified it, so now it works as you want. Basically I set the BindingPath Property of the UnboudFiedlfto "DataProperty". This way the unbound field is connected to the DataSource. Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.
Hi Stefan,
I'm sorry for the late response - I was given other work to do as soon as I posted this up. But, now I'm trying to tackle this again and would appreciate your help :)
I've attached a sample project that shows what I'm trying to accomplish. I need an unbound field because in my main project, I use data converters as the data is more complex. However, this simple sample shows the sorting problem, where the sorter is being passed NULL. All you have to do is push the column header to try to sort it (column A).
I understand why it's null - I don't think the 'value' for the field is set anywhere, but I couldn't figure out where to set it. I've tried some things, but instead of just mixing up the sample, I've left it out. If you can help me sort this sample project, I believe I'll be able to apply it back to my main project.
Thanks for your time,
-Ryan-
It has been a while since you have made your post, in case you still need support I will be glad to assist you further. I suppose the other community members can benefit from this answer as well. I have been looking into your post, but it seems like that I am missing something in your scenario, so if this is still an issue for you, could you please send an isolated sample project, where the issue is reproduced, so I can investigate it further for you.
Feel free to write me if you have further questions.