我正在使用Angular 4 中的Kendo网格。我需要一列中的所有单元格才能显示本地货币。这可能吗?
...
<kendo-grid-column
field="unitPrice"
format="currency" // <- for clearity: I need to do something like this.
[title]="Unit Price">
</kendo-grid-column>
似乎肯德(Kendo(要求您声明格式并提供该语言环境。
kendo列
<kendo-grid-column
field="unitPrice"
filter="numeric"
format="{0:c}"
[title]="'formsPlus.lineItemAttach.unitPrice' | translate"
[width]="100">
</kendo-grid-column>
your.module.ts
import { LOCALE_ID, NgModule } from "@angular/core"
...
@NgModule({
...
providers: [
{ provide: LOCALE_ID, useValue: "en-US" },
],
由于某种原因,如果不提供LOCALE_ID
。
旁注:您可以通过将语言环境导入到您的模块中来更改启动的语言:
import "@progress/kendo-angular-intl/locales/fr/all"
...
...
{ provide: LOCALE_ID, useValue: "fr" },
是的,可以肯定,您可以做到。
从Kendo UI网格本地化演示中检查以下代码
element.kendoGrid({
dataSource: dataSource,
pageable: {
refresh: true,
pageSizes: true,
buttonCount: 5
},
filterable: true,
sortable: true,
columnMenu: true,
toolbar: ["create"],
columns: [
"ProductName",
{ field: "UnitPrice", title: "Unit Price", format: "{0:c}", width: "120px" },
{ field: "UnitsInStock", title:"Units In Stock", width: "140px" },
{ field: "Discontinued", width: "140px" },
{ command: ["edit", "destroy"], title: "", width: "260px" }],
editable: "inline"
});
观察UnitPrice
的字段是根据column
中提供的format
格式化的 { field: "UnitPrice", title: "Unit Price", format: "{0:c}", width: "120px" }
有关更多参考,您可以检查Kendo本地化文档
更新:
对于Angular 2 ,不会有太大的区别。
您可以在下面进行标记。
<kendo-grid-column
field="unitPrice"
format="{0:c}" // or format="'{0:c}'"
[title]="Unit Price">
</kendo-grid-column>