Hi, I am using a xamGrid in Silverlight.
I am using auto-generate columns.
One of my columns is a DateColumn, its data source is .Net DateTime object.
There are 2 problems -
1)
The column displays correctly at first with little calendars in each cell of the date column.
But if you scroll the grid the date displayed on each calendar loses its value and gets displayed as D/MM/yy.
2)
How do I format the date column? All of the samples I could find on the web refered to TextColumn and FormatString which is not available for DateColumn.
I don't want to convert to text as I want to use a filter on the column and this won't work if the column is treated as text.
Kind Regards, David.
Hi,
I believe your first issue is a bug in the control that was fixed a while ago. Upgrading to the latest SR should fix the problem.
As for the second one, you can set an EditorStyle on the column and set the SelectedDateFormat property of the date picker in this style:
<Style x:Key="LongDateStyle" TargetType="sdk:DatePicker"> <Setter Property="SelectedDateFormat" Value="Long" /> </Style>
<ig:XamGrid> <ig:XamGrid.Columns> <ig:DateColumn Key="LongDateTime" EditorStyle="{StaticResource LongDateStyle}" /> </ig:XamGrid.Columns> </ig:XamGrid>
In 11.1, we're adding the SelectedDateFormat property on the DateColumn, which should make this easier.
Hope this helps,
Hi Georgi,
Thanks for your help.
I applied your suggested fixes and they both worked.
Unfortunately I still have a problem. I need to display the time as well as the date. It guess your DateColumn is based on the sdk:DatePicker control. This only has two options for format - "Short" or "Long", which both only display the date. Is there any way to display both dates AND times in the xamGrid?
Hi David,
Your guess is correct - the DateColumn uses a DatePicker control for displaying and editing the values.
What you can do is to implement your own DateTimePicker control and use it for displaying and editing datetime values in XamGrid. You can create a custom column that inherits from DateColumn and extend it to use your custom control for this purpose.
Here's an article on how to create a custom column:
http://blogs.infragistics.com/blogs/devin_rader/archive/2010/07/08/creating-custom-columns-for-xamgrid.aspx
Basically, you'd want to create a custom column, deriving from DateColumn, and custom ColumnContentProvider deriving from DateColumnContentProvider.
Then, you'll need to override the ResolveDisplayElement and ResolveEditorControl methods in your derived ColumnContentProvider to return your custom DateTimePicker control.
When you do this, what is required in order to maintain sorting and filtering capabilities for dateTime?
If you derive a column from DateColumn and and Provider from DateColumnContentProvider and use even a standard datepicker binding in ResolveDisplayElement and return the datePicker in ResolveEditorControl, the sorting seems to be broken and the filtering for specialized filters for things like contains, and not equals appears to be broken as well.
What is the approach one is supposed to take for implementing this custom dateColumn so that things like sorting and filtering stay intact?
Is there any progress on this front? We need the same functionality of having both date and time displayed.
Many people store a date and time together in one column. Having to create a custom column for that sounds like a major oversight in the development of xamGrid. The library should have a setting for DateTime columns that specifies whether it is just a Date, or a Date and a Time (or perhaps just a time). An editor for each should be built in. Perhaps the setting should be a DateTimeFormatInfo that would override the default culture settings?
At the very least, please provide a link to all of the necessary code so lots of time :-) can be saved.
thanks for your help Gerogi