New DateTimeColumn for the Infragistics XamGrid in 2012.1

Atanas Dyulgerov / Wednesday, April 25, 2012

In previous versions of NetAdvantage for SL and WPF you had two options to handle columns with DateTime format. The first one was to use the DateColumn, which displayed your date appropriately and provided a date time picker to input the date – nothing shocking there. The other way was to add a text column and provide value converter to display the date and provide a editor template that uses the masked input control that would ensure the correct format of the date. Then you could do some complicated things to combine that mask editor with a date picker. In the upcoming 2012.1 release you no longer need to do complicated stuff to get a mask editor and dropdown. We have included the awesome DateTimeColumn.

It is shipped in its own assembly that you have to add to the ones you normally add for a XamGrid. Its called InfragisticsSL5.Controls.Grids.DateTimeColumn.v12.1. There are two requirements that you also need to include: InfragisticsSL5.Controls.Editors.XamDateTimeInput.v12.1 and InfragisticsSL5.Controls.Editors.XamMaskedInput.v12.1

As you see on the screenshot you can either enter the date by typing and the mask editor will take care for the format or you can select the date from the date picker.

Here is the code that created the screenshot above

 

  1. <ig:XamGrid x:Name="grid" >
  2.     <ig:XamGrid.EditingSettings>
  3.         <ig:EditingSettings AllowEditing="Cell" />
  4.     </ig:XamGrid.EditingSettings>
  5.     <ig:XamGrid.Columns>
  6.         <ig:TextColumn Key="Name" />
  7.         <ig:DateTimeColumn Key="Time" SelectedDateMask="{}{date} {time}" />
  8.     </ig:XamGrid.Columns>
  9. </ig:XamGrid>

 

You can use this column like any other standard type of column. You only have to specify the mask for the date.  For a full list of valid masks check this link.

Also note that DateColumn still exists for backward compatibility.

I hope this has been interesting and helpful. Have a great day!