We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

DateTimeEdit and TimeSpanEdit in a GridTreeColumn

What is the best way to set a custom pattern format to a DateTimeEdit and TimeSpanEdit Column of a GridTreeControl? I did the following way, but it doesn't work:

new GridTreeColumn() { StyleInfo = new GridStyleInfo() { CellType = "DateTimeEdit", Format "dddd, dd.MM.yyyy hh:mm", HorizontalAlignment = HorizontalAlignment.Center

new GridTreeColumn() { StyleInfo = new GridStyleInfo() { CellType = "TimeSpanEdit", Format = " h 'h' m 'min'", HorizontalAlignment = HorizontalAlignment.Center }

 

 


3 Replies

TV Thangapriya V Syncfusion Team June 4, 2013 06:59 AM UTC

Hi Andreas,

We have analyzed your query and you can set DateTimePattern as CustomPattern for using custom DateTime format. You can refer the following code snippet for this.

Code snippet [XAML]:

<syncfusion:GridTreeColumn MappingName="DOJ" HeaderText="DateTimeEdit">

                        <syncfusion:GridTreeColumn.StyleInfo>

                            <syncfusion:GridDataColumnStyle CellType="DateTimeEdit">

                                <syncfusion:GridDataColumnStyle.DateTimeEdit>

                                    <syncfusion:GridDateTimeEditStyleInfo  DateTimePattern="CustomPattern" CustomPattern="dddd, dd.MM.yyyy hh:mm"/>

                                </syncfusion:GridDataColumnStyle.DateTimeEdit>

                            </syncfusion:GridDataColumnStyle>

                        </syncfusion:GridTreeColumn.StyleInfo>     </syncfusion:GridTreeColumn>

              

 

We have prepared a sample based on your requirement and please find the sample under the following location.

Please let us know if you have any queries.

Regards,

Thangapriya



CellEditorsDemo_9d1b1b72.zip


AS Andreas Sommer July 4, 2013 01:25 PM UTC

Sorry I need it by c# code not in XAML language. Thanks.


TV Thangapriya V Syncfusion Team August 5, 2013 08:39 AM UTC

Hi Andreas,


Apologize for the delay caused. 


We suggest you to set CustomPattern for DateTimeEdit and TimeSpanEdit in code behind as follows.


Code snippet[C#]:

treeGrid.ModelLoaded += new EventHandler(treeGrid_ModelLoaded);


void treeGrid_ModelLoaded(object sender, EventArgs e)

{

GridTreeColumn column1 = new GridTreeColumn() { MappingName="DOJ", StyleInfo = new GridStyleInfo() { CellType = "DateTimeEdit", DateTimeEdit = new GridDateTimeEditStyleInfo() { DateTimePattern=DateTimePattern.CustomPattern, CustomPattern = "dddd, dd.MM.yyyy hh:mm" } } };

treeGrid.Columns.Add(column1);

GridTreeColumn column2 = new GridTreeColumn() { MappingName = "Time", StyleInfo = new GridStyleInfo() { CellType = "TimeSpanEdit", TimeSpanEdit = new GridTimeSpanEditStyleInfo() { Format = " h 'h' m 'min'" } } };

treeGrid.Columns.Add(column2);

}





Please let us know if you have any queries.


Regards,

Thangapriya


Loader.
Live Chat Icon For mobile
Up arrow icon