This is a migrated thread and some comments may be shown as answers.

Grid Displaying text for value not working on grid column

2 Answers 738 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Van
Top achievements
Rank 1
Van asked on 08 Jul 2020, 07:30 AM

Hi,

I'm working on Kendo Grid with Angular 1.7 with Typescript. So far, displaying dropdown list during edit (popup) mode is working as expected. I'm currently struggling with displaying text instead of bound value on grid column. The model of data source includes 2 properties: "Label" and "Id". I've tried to follow these examples:

1. https://demos.telerik.com/kendo-ui/grid/foreignkeycolumnbinding

2. https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/configuration/columns.values

but with no luck. After "Update" button is clicked, the grid shows "Id" instead of "Label".

Here is my custom editor:

columnConfig.editor = (container, options) => {
      $('<input required data-text-field="Label" data-value-field="Id" data-bind="value:' + options.field + '" /> ')
        .appendTo(container)
        .kendoDropDownList({
             autoBind: false,
             dataTextField: "Label",
             dataValueField: "Id",
                 dataSource: {
                      data: CustomPickListItems
                  }
             });
        };

 

How can I make the grid display "Label" but save "Id" to local data?

2 Answers, 1 is accepted

Sort by
0
Preslav
Telerik team
answered on 10 Jul 2020, 07:32 AM

Hi Van,

To modify the column display, I would suggest using the columns.template property - https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/configuration/columns.template

For example, check this demo - https://demos.telerik.com/kendo-ui/grid/editing-custom

In the demo, the template of the "Category" column looks like:

template: "#=Category.CategoryName#"

Regards,
Preslav
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Van
Top achievements
Rank 1
answered on 06 Aug 2020, 06:11 PM
Thank you! I'm able to get it work by using template.
Tags
Grid
Asked by
Van
Top achievements
Rank 1
Answers by
Preslav
Telerik team
Van
Top achievements
Rank 1
Share this question
or