简体   繁体   中英

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

I created this 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. 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.


Here's some code:
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

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). 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. Not sure if thats what you are looking for, I have done something similar to that in kendo MVC.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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