kkaragki
kkaragki

Reputation: 150

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. 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!

Upvotes: 0

Views: 368

Answers (1)

Kevin
Kevin

Reputation: 333

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.

Upvotes: 1

Related Questions