我尝试格式化日期列,如下所示,settings
以及date-format
直接属性。两者都不起作用。列类型设置为date
,提供的数据类型为date
。ngHandsontable:日期格式在热列指令中不起作用
<hot-column data="createdAt" title="'Date'" type="'date'"
settings="{dateFormat:'DD/MM/YYYY', type: 'date'}"
date-format="'DD/MM/YYYY'"
correct-format="true"
allow-empty="true" read-only></hot-column>
日期列将不会格式化。其他类型的格式,例如使用format
-attributes的Severity列中的numeric
类型正在工作。
完整的表码:
<hot-table read-only datarows="events" class="table table-bordered table-striped" row-headers="false" manual-column-resize="true">
<hot-column data="createdAt" title="'Date'" type="'date'"
settings="{dateFormat:'DD/MM/YYYY', type: 'date'}"
date-format="'DD/MM/YYYY'"
correct-format="true"
allow-empty="true" read-only></hot-column>
<hot-column data="eventType" title="'Event Type'"></hot-column>
<hot-column data="user.displayName" title="'User'"></hot-column>
<hot-column data="ipAddress" title="'IP Address'"></hot-column>
<hot-column data="severity" title="'Severity'" type="'numeric'" format="'$ 0,0.00'"></hot-column>
<hot-column data="eventMessage" title="'Message'"></hot-column>
<hot-column data="" title="'Old data'"></hot-column>
<hot-column data="" title="'New data'"></hot-column>
</hot-table>
使用ngHandsontable 0.12.0,Handsontable 0.26.1。
遗憾的是,没有一个demo可用,使用date-format
属性。
我目前的解决方法是使用自定义渲染器,并通过moment()
在那里格式化日期。
在这里创建一张票:https://github.com/handsontable/ngHandsontable/issues/178 –