2014-03-27 31 views
0

我正在學習Kendo UI,並遵循walkthroughs之一。我有一個網格工作,但日期格式不起作用,出於某種原因。爲什麼格式化我的KendoGrid列不起作用?

$("#archiveGrid").kendoGrid({ 
    columns: [ 
     { field: "SentDate", title: "Sent", format: "{0:MM/dd/yyyy}" }, 
     { field: "SenderName", title: "Sender" }, 
     { field: "SenderEmail", title: "Email" }, 
     "Subject" 
    ], 
    dataSource: new kendo.data.DataSource({ 
     transport: { 
      read: "api/messages" 
     }, 
     pageSize: 15, 
     serverPaging: true, 
     schema: { 
      data: "Data", 
      total: "Count" 
     } 
    }), 
    pageable: true 
}); 

但我的日期仍然看起來像2014-02-07T21:06:03.993。我測試了網格忽略format屬性的理論,並將格式字符串更改爲"foo {0:MM/dd/yyyy}",這使日期顯示爲foo 2014-02-07T21:06:03.993

那麼我做錯了什麼?

回答

1

您在DataSource中缺少模型。嘗試添加一個合適的模型並將其類型設置爲date。那麼格式將正常工作,也不要忘記提及該ID。

schema: { 
       id: "Id", 
       data: "Data", 
       total: "Count", 
       fields: { 
         SentDate: { editable: true, type: "date"}, 
         SenderName: { editable: true}, 
         SenderName: { editable: true} 
        } 
      } 
+0

+1 Bingo。謝謝! –

相關問題