2016-08-03 17 views
1

DateTimeオブジェクトを剣道リストビューテンプレートに書式設定しようとしていますが、提案されたkendo.toStringメソッドが動作しないようです。剣道の書式日付

私は問題に関連しない多くのコードを切り捨てて、理解しやすくしました。

私は次のようになります。Kendo DataSourceを持っている:

contactDataSource: new kendo.data.DataSource({ 
    transport: { 
     read: { 
      url: "/baa/contact/getcontacts", 
      dataType: "json", 
      type: "GET" 
     } 
    }, 
    schema: { 
     model: { 
      id: "Id", 
      fields: { 
       Id: { type: "number", editable: false, nullable: true }, 
       CompanyName: { type: "string" }, 
       ContactName: { type: "string" }, 
       ContactPhone: { type: "string" }, 
       ContactEmail: { type: "string" }, 
       ImageUrl: { type: "string" }, 
       Website: { type: "string" }, 
       RecentBaas: [ 
        { 
         Name: { type: "string" }, 
         StatusDisplay: { type: "string" }, 
         Status: { type: "number" }, 
         LastModDate: { type: "date" } 
        } 
       ] 
      } 
     } 
    } 
}) 

そして私は、次のようになります。私の見解でテンプレートがあります。

<script type="text/x-kendo-templ" id="contactTemplate"> 
    <div class="row"> 
     <div class="col-md-12"> 
      # for (var i = 0; i < RecentBaas.length; i++) { # 
      # if (RecentBaas[i].Status == 1) { # 
       <div class="alert alert-success" role="alert"> 
        <p>#=kendo.toString(RecentBaas[i].LastModDate, "F")#</p> 
       </div> 
      # } # 
      # } # 
     </div> 
    </div> 
</script> 

私はすべてのエラーを取得していないよとこのページをロードすると私のコンソールに表示されますが、日付はまったくフォーマットされていません。それはまだ例えば/Date(1461203814927)/と表示されます。

toStringの機能を使用してDateTimeオブジェクトをフォーマットする方法については、剣道のドキュメントを読んでいます。しかし、私はまだ何かが欠けているかもしれない?

答えて

2

次のコードスニペットを試してください。

<script type="text/x-kendo-templ" id="contactTemplate"> 
    <div class="row"> 
     <div class="col-md-12"> 
      # for (var i = 0; i < RecentBaas.length; i++) { # 
      # if (RecentBaas[i].Status == 1) { # 
       <div class="alert alert-success" role="alert"> <p>#=kendo.toString(kendo.parseDate(RecentBaas[i].LastModDate), 'yyyy-MM-dd')#</p> 
       </div> 
      # } # 
      # } # 
     </div> 
    </div> 
</script> 

そのが働い

+0

うん動作しない場合は、私に教えてください!私はまずそれを解析しなければならないとは思わなかった。なぜなら、私が前に解析していないことを誓うことができたからだ。しかし、ありがとう! – Quiver

関連する問題