简体   繁体   English

如何在剑道网格行中动态更改货币

[英]How can I dynamically change currency in a Kendo-grid row

I created this kendo-grid : 我创建了这个kendo-grid 剑道网 What I'm trying to implement is: Whenever I change the currency select option, I want to change the currency ONLY in that row, so that I will be able to have multiple currency entries below in my grid. 我想要实现的是:每当我更改货币select的选择,我想改变货币在该行,这样我就可以在我的网格下方多种货币的条目。 I found documentation here , and I tried the exact same code, but I realised that every time I change the option the whole culture in my Web Application changes. 我在这里找到了文档,并且尝试了完全相同的代码,但是我意识到,每次更改option ,Web应用程序中的整个区域都会更改。


Here's some code: 这是一些代码:
debts.component.html debts.component.html

<kendo-grid #creditorsGrid
    id="creditorsGrid"
    [data]="gridData"
    ...>
    <ng-template kendoGridToolbarTemplate>
      ...
    </ng-template>
    <kendo-grid-column field="ID" title="Α/Α" width="50"></kendo-grid-column>
    <kendo-grid-column field="CreditorName" title="Πιστωτής">
      <ng-template kendoGridCellTemplate let-dataItem="dataItem">
        <kendo-combobox [data]="creditorsListItems" [suggest]="true"></kendo-combobox>
      </ng-template>
    </kendo-grid-column>
    <kendo-grid-column field="Amount" title="Ποσό" editor="numeric" format="{0:c}"></kendo-grid-column>
    <kendo-grid-column field="Currency" title="Νόμισμα" width="100">
       <ng-template kendoGridCellTemplate let-dataItem="dataItem">
        <select style="width:65px" [value]="localeId" (change)="onLocaleChange($event.target.value)">
          <option value="en-DE">€</option>
          <option value="en-GB">£</option>
          <option value="en-CH">Fr.</option>
          <option value="en">$</option>
        </select>
      </ng-template>
    </kendo-grid-column>
    <kendo-grid-command-column width="100">
      ...
    </kendo-grid-command-column>
</kendo-grid>

debts.compoenent.ts debts.compoenent.ts

export class DebtsComponent implements OnInit {

    constructor(private formBuilder: FormBuilder, public editService: EditService,
              public intlService: IntlService, private localeService: LocaleService) { }

    public get localeId(): string {
        return this.localeService.localeId;
    }

    public onLocaleChange(locale: string): void {
        this.localeService.set(locale);
    }

}

(The localeService is found in the documentation page I mentioned above). (可以在上面提到的文档页面中找到localeService )。 Thanks in advance! 提前致谢!

If you make your currency an Enum type it should allow you to just be able to select that Enum for each of your currencies. 如果您将货币设为Enum类型,则应该可以为每种货币选择该Enum。 Not sure if thats what you are looking for, I have done something similar to that in kendo MVC. 不知道这就是您要寻找的东西,我已经做了与kendo MVC类似的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM