Hi,
I am having a grid which will display the Date/Time string.
My DTO is having two members called. 'ModifiedTime' and 'ModifiedTimeString'. The second member will convert the datetime to a defined format [dd/MM/yyyy HH:mm]. Field 'ModifiedTimeString' is added to xamdatagrid.Is that possible that when the user tries to sort the 'ModifiedTimeString' field the grid should get sorted based on the data member 'ModifiedTime'? I tried IComparer, but i'm unable to convert the text as date/time (it is giving a error 'connot convert, invalid string').
Can somebody help me in this regard? Thanx in advance.
Hello,
You don't need to use a ModifiedTimeString. You can modify the way your date time value appears in the XamDataGrid by setting a style for its XamTextEditor.
Here is a style that should satisfy you:
<Style TargetType="{x:Type igEditors:XamTextEditor}" x:Key="TheTextStyle"> <Setter Property="Format" Value="dd/MM/yyyy HH:mm" /> </Style>
And here is how to set it:
<igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout> <igDP:FieldLayout.Fields>
<igDP:Field Name="Hire Date"> <igDP:Field.Settings> <igDP:FieldSettings EditAsType="{x:Type sys:String}" EditorType="{x:Type igEditors:XamTextEditor}" EditorStyle="{StaticResource TheTextStyle}" /> </igDP:Field.Settings> </igDP:Field>
</igDP:FieldLayout.Fields> </igDP:FieldLayout></igDP:XamDataGrid.FieldLayouts>
After which the column HireDate sorts like all the other columns by clicking on the header.
Hope this helps.
Regards Petar.
Thanks a lot Petar. It works
But, can we sort a column based on another member?
Thanks once again
Take a look at this link. I think this is the same issue:
http://forums.infragistics.com/forums/p/5713/25585.aspx
Tell me if this helps.