Author Topic: select list  (Read 363 times)

omerix

  • Pro Enterprise
  • Full Member
  • *
  • Posts: 148
    • View Profile
select list
« on: August 29, 2023, 04:14:30 pm »
Hello,

I have a selectable column with Select.

In this column, I choose from the itemlist field with value and label values.

The editing user doesn't need to see the id at all. But I am sending the id value to data and saving it.

I have an explanation called id_label, here I print the id_label field with "render text" for the user to understand.

No problem with recording and display.

But after the current data comes, in the 1st line, for example, I choose "needle" instead of "mask", but the "mask" still appears on the screen.

In fact, identity is changing. With console.log(ui.cellData) I see that the data has changed but after changing the selection the label on the screen is wrong.


https://jsfiddle.net/omerx/pye705ua/1/

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6314
    • View Profile
Re: select list
« Reply #1 on: August 29, 2023, 07:12:22 pm »
You need to update column.render callback

Code: [Select]
render: function(ui) {
  //console.log(ui.cellData);
  return {   
    //text: itemlistObj[ui.cellData] //this can also be used.
    text: itemlist.find( item => item.value==ui.cellData).label
  }
}

And there is no need to store id_label values in the rowData.

https://jsfiddle.net/2cdg1fLo/
« Last Edit: August 29, 2023, 07:14:53 pm by paramvir »

omerix

  • Pro Enterprise
  • Full Member
  • *
  • Posts: 148
    • View Profile
Re: select list
« Reply #2 on: September 12, 2023, 10:13:05 am »
Thanks. There was a problem when opening a mismatched element or a new line (when an empty line was opened), it gave a "reading" error. It works very well this way.

Code: [Select]
text: itemlist.find( item => item.value==ui.cellData)?.label || ''