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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

DateTimeEdit and TimeSpanEdit in a GridTreeColumn

Thread ID:

Created:

Updated:

Platform:

Replies:

109169 Jun 1,2013 03:20 PM UTC Aug 5,2013 08:39 AM UTC WPF 3
loading
Tags: GridControl
Andreas Sommer
Asked On June 1, 2013 03:20 PM UTC

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 }

 

 


Thangapriya V [Syncfusion]
Replied On 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

Andreas Sommer
Replied On July 4, 2013 01:25 PM UTC

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

Thangapriya V [Syncfusion]
Replied On 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


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;