valueField and displayField

Hi,

I have a databound listGrid where one of the fields is linked to another datasource with many records - it is used to add new products to a category.
Of course I want to show meaningful names of the products instead of some numerical ids and I want that user can pick a product by its name in a comboBox used as an editor for this field.

Here is part of main DataSource:

  fields: [
    {name: "category_product_id", type: "integer", primaryKey: true, hidden: true},
    {name: "category_id", required: true, type: "integer", canEdit: true},
    {name: "product_id", required: true},
    {name: "product_name", canEdit: true, hidden: true}
  ]

Here is part of ComboBox Datasource:

  fields: [
    {name: "product_id", canEdit: false},
    {name: "product_name", canEdit: false}
  ]

And here is my question:
What values should I put into valueField and DisplayField for ListGridField and ComboBox to achieve what I want to achieve?

Currently I have something like this:

  fields: [
    {name: "category_id"},
    {name: "product_id", valueField: "product_id", displayField: "product_name", editorType: "ComboBoxItem", editorProperties: {textMatchStyle: "substring", optionDataSource: products_picklist, valueField: "product_id", displayField: "product_name"}
    }
  ]

I can pick a product using ComboBox by its product_name, but it appears in the ListGrid as its product_id in blue. At the same time “add” command is sent to server with fields:

category_id: 7
product_id: 133
product_name: 133

Product id is both in product_id and product_name.

Second after, server responds with full record that has been added sending proper product_name to main Datasource and a record in ListGrid turns black and start to show product_name.

I believe that I have messed up something with valueFields and displayFields but I can’t sort it out.

Thanks in advance for your help.

Regards,
Janusz

Get rid of your setting for ListGridField.valueField and ListGridField.displayField (retain the valueField and displayField setting within editorPropreties). Check the docs for what these do - they aren’t relevant in your use case.