Format DateTime in Kendo UI Grid using asp.net MVC Wrapper

前端 未结 8 518
执念已碎
执念已碎 2021-02-01 14:38

I want to build a Kendo UI Grid with format date dd//MM/yyyy. However, all questions that I found about this, it were resolved with code Format(\"{0:d}\");. So,

相关标签:
8条回答
  • 2021-02-01 14:56

    If you want to display datetime format in kendo grid then do this,

    .Format("{0:dd/MM/yyyy}") 
    

    Or

    builder.ToString("dd/MM/yyyy");
    
    0 讨论(0)
  • 2021-02-01 15:00

    Can also use:

    columns.Bound(c => c.DateCreate).Format("{0:G}")
    

    As in http://docs.telerik.com/kendo-ui/framework/globalization/dateformatting

    0 讨论(0)
  • 2021-02-01 15:00

    Try instead this,this will work.

    .ClientTemplate("#= kendo.toString(kendo.parseDate(Date,'dd/MM/yyyy'), '" +  CurrentDateFormat + "') #");
    
    0 讨论(0)
  • 2021-02-01 15:01

    The other solutions were close but no cigar... Here's what worked for me:

    columns.Bound(c => c.CreatedDate).ClientTemplate("#= kendo.toString(kendo.parseDate(CreatedDate), 'dd/MM/yyyy') #");
    
    0 讨论(0)
  • 2021-02-01 15:02

    I don't know about Kendo UI but it looks to me like you want to pass a string formatted date rather than a DateTime object.

    The /Date(...)/ output looks like a JSON formatted date from .Net.

    I would convert the date to a string using somthing like myDateTime.ToString("dd/MM/yyyy"); before passing it to the control.

    0 讨论(0)
  • 2021-02-01 15:03
    .Format("{0:" + System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern + "}");
    

    There may be some other options in System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat that might work for you if that is not what you want.

    0 讨论(0)
提交回复
热议问题