angularjsng-gridangular-ui-grid

Showing readable data in ui-grid with editable drop-down cell


I have a editable angular-ui-grid, where my editable column in columnDefs object is defined as

columnDefs: [ {   
                name: "rightslist",
                displayNameKey: tr.rightsList,
                editableCellTemplate: 'ui-grid/dropdownEditor',
                editDropdownOptionsArray: [{name: 'Read-Only', value: 1}, {name: 'Read-Write', value: 2}],
                editDropdownIdLabel: 'value',
                editDropdownValueLabel: 'name',           
                enableCellEdit: true
            }]

The drop-down shows just fine showing me "Read-Only" and "Read-Write", but when it is closed, in the grid I see not the "name" but "value" (1 or 2).

In ui-grid example here display of cell is implemented using a filer that turns such value to a text. Is there any simpler way to tell "show me name, not value when cell is not being edited" ?


Solution

  • Since you don't want a filter, I assume the text is in the model field. If that is the case then I can think of two solutions.

    1. Replace the "value: 1" with "value: 'Read-Only'" or
    2. Change editDropdownIdLabel to 'name'

    I know 1 works - I haven't tried 2.