akveo / ng2-smart-table

Angular Smart Data Table component
https://akveo.github.io/ng2-smart-table/
MIT License
1.63k stars 877 forks source link

showing dropdown value in edit mode #665

Open thilankascentic opened 6 years ago

thilankascentic commented 6 years ago

Hi !,

Im my table, I have dropdown columns, when I click on edit link, cell value clearing, can anyone help me to figure this please?

image

DependencyHell commented 6 years ago

@thilankascentic

The value from the cell must be equal to the corresponding title in your list.

So, I couldn't manage to make it work with a column property of type Object.

Instead I had to create a new property of type String, in which I assigned my Object.id value. Then I need to retrieve corresponding title from the id.

In example :

daysOfTheWeekList: [{ value: 0, title: 'Monday' }, { value: 1, title: 'Tuesday' }]
...
my_day_value: {
  title: 'Day',
  editor: {
    type: 'list',
    config: {
      list : this.daysOfTheWeekList
    }
  },
  valuePrepareFunction: (cell) => {
    return this.findDayNameById(cell);
  }
},
...

Function findDayNameById returns the title from the given value into the daysOfTheWeekList list.


Related to : https://github.com/akveo/ng2-smart-table/issues/580 - Titles of dropdown cells https://github.com/akveo/ng2-smart-table/issues/10 - Input Select

rheineo commented 5 years ago

resolved:

#233

DoniaBA commented 5 years ago

Hello! did you solve this eventually?

ShaileshNandkule commented 5 years ago

hello, I am facing the same above issue. I went through the above posts but not able to figure out the exact solution for the problem. did you able to solve this problem??