Hello, How to set the grid cell level date format and input mask for dd-MMM-yy (25-May-23) format ? I tried with date editor component but nothing working. Please assist. Thanks
Hello Shawn,
You can apply format for the column with the following code:
this.ultraGrid1.DisplayLayout.Bands[0].Columns["Date"].Format = "dd-MMM-yy";
This would apply the correct format out of edit mode, the reason why you are not able to add MaskInput is that “MMM” is text and by design DateTimeColumns are handled with UltraDateTimeEditor, which only handles numbers in its edit mode. Once the user enters edit mode a calendar would appear and the date 29-May-2023 would appear as 29-05-2023, which the user would be able to edit through the keyboard and the calendar.
Another alternative would be to use UltraCalendar combo as EditorComponent for the column. By doing this you would be able set the correct format - "dd-MMM-yy" for both in and out of edit mode. It could be done with the following code:
UltraCalendarCombo calendarCombo = new UltraCalendarCombo(); this.ultraGrid1.DisplayLayout.Bands[0].Columns["Date"].EditorComponent = calendarCombo; this.ultraGrid1.DisplayLayout.Bands[0].Columns["Date"].Format = "dd-MMM-yy"; this.ultraGrid1.DisplayLayout.Bands[0].Columns["Date"].MaskInput = "dd-MMM-yy";
Please try both approaches and let me know if you have any questions.
Regards, Ivan Kitanov
Dear Ivan,
Thank you so much for your reply. I did it as per your second method assigning UltraCalendarCombo EditorComponent in the date grid cell. All working perfectly as expected.
Thank you,
Regards,
Shawn
I’m glad I was able to help.
Thank you for choosing Infragistics.