skip to Main Content

I’m working on an Angular application that utilizes DevExtreme components, and I’ve encountered an issue with customizing the display of data in a DataGrid component. I have a column named "Type" that displays codes from a database, such as YPT, QRT, and QRI. Instead of directly displaying these codes, I would like the column to display user-friendly names.
Specifically, instead of QRT I want to display "tests", and instead of QRI – "reports". The rest of the codes can be displayed as is.
Here’s a snippet of my code related to the column:

<dxi-column dataField="Type"
            caption="Type"
            [allowEditing]="true">
</dxi-column>

I tried using cellTemplate to achieve this goal but am having difficulty implementing the conditional logic to change the text displayed in the cell. Could someone show me how to properly implement this functionality in Angular using DevExtreme?

Thank you for any help!

I tried:


<dxi-column dataField="IsCompleted"
            caption="Status"
            [allowEditing]="false"
            [lookup]="{
        dataSource: [{ id: 0, text: 'Nie ukończone' },
                     { id: 1, text: 'Zapisane - nie wysłane' },
                     { id: 2, text: 'Ukończone - wysłane' }],
        valueExpr: 'id',
        displayExpr: 'text'
    }">
</dxi-column>

2

Answers


  1. Try to remove allowEditing attribute from dxi-column and and if need to allow to edit values of column, move it to dxo-editing property.

    Login or Signup to reply.
  2. In my opinion, the best way to accomplish this is the use of dxo-lookup.
    This way you can bind a datasource configuration/datastore to the types column and set a display expression.

    Link to documentation: https://js.devexpress.com/Angular/Documentation/Guide/UI_Components/DataGrid/Columns/Column_Types/Lookup_Columns/

    example: https://codesandbox.io/p/sandbox/broken-worker-96p4lm?file=%2Fsrc%2Fapp%2Fapp.component.html%3A21%2C38

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search