<e-column field='property.selectedUnit' headerText="{{'txt.Unit' | translate}}">The data source of the combo box is in the data row as an array of objects (in the fields the id is the 'name' and the value is the name). When I enter edit mode in the cell, the combox is draw correctrly, with the selectedUnit current value selected. When I changed the value and finish edit, the cell draw the selectedUnit as an Object (screenshot attached). I'm not sure why this is happening, the data of the row the selectedUnit is the string of name.
<!-- <ng-template #template let-data>-->
<!-- {{data.property.selectedUnit | translate}}-->
<!-- </ng-template>-->
<ng-template #editTemplate let-data>
<ejs-combobox id="unitCombo"
[sortOrder]="'Ascending'"
[showClearButton]="false"
[fields]="{text: 'name', value: 'name'}"
[dataSource]="data.property.unitProfilesSet"
[value]="data.property.selectedUnit"
(valueChange)="unitChange($event,data)"
>
</ejs-combobox>
<!-- <ng-template #template let-upData>-->
<!-- {{upData.name | translate}}-->
<!-- </ng-template>-->
</ng-template>
</e-column>
|
<ejs-grid #grid id='grid' allowPaging='true' [pageSettings]='pageSettings' [dataSource]='pData' [editSettings]='editSettings' [toolbar]='toolbar'>
<e-columns>
<e-column field='City' headerText='City' [edit]='cbParams' width=150></e-column>
</e-columns>
</ejs-grid> |
|
export class AppComponent implements OnInit {
.
.
public elem: HTMLElement;
public comboboxObj: ComboBox;
public cbParams: IEditCell;
ngOnInit() {
this.cbParams = {
create: () => {
// Input element is created for appending the combo box
this.elem = document.createElement('input');
return this.elem;
},
read: () => {
// The combo box value to be saved in the Grid is returned here
return this.comboboxObj.value;
},
destroy: () => {
this.comboboxObj.destroy();
},
write: (args: { rowData: object, column: Column }) => {
// Combo box is created and appended to the form element
this.comboboxObj = new ComboBox({
sortOrder: "Ascending",
showClearButton: false,
fields: {text: 'name', value: 'name'},
dataSource: this.comboData,
value: args.rowData["City"]
});
this.comboboxObj.appendTo(this.elem);
}
};
}
} |
<ng-template #template let-upData> {{upData.name | translate}} </ng-template>|
export class AppComponent implements OnInit {
// Here you can translate the required values and append it to the below template string
public comboTemplate = "<span class='custom'>${name}</span>"
.
.
// Edit params function
this.cbParams = {
.
.
write: (args: { rowData: object, column: Column }) => {
this.comboboxObj = new ComboBox({
.
.
itemTemplate: this.comboTemplate,
fields: { text: 'name', value: 'name' }
});
this.comboboxObj.appendTo(this.elem);
}
} |
|
dataSource: (this.comboData as { [key: string]: Object; } []), |