DataTable - How can I map a column to a specific field in a JSON object

I am having some problem mapping a column to a specific field in a JSON object.

Each of the row in my data has the following structure:

{
name: "Paul",
status: {
   id: 1,
   value: 'Single'
}
}

I am trying to map a column to status.id. I have tried the follow, but it doesn't seem to work:

{
columns : [
  {  id: 'status', map:'#status.id#', editor:'select'
]
}

The purpose for doing this is so that I can use the select editor to update the ID of status.

Tagged:

Comments

  • edited July 2017

    Data mapping assigns the value to the newly created data attribute (which will be edited). There's no built-in solution to update the nested data with the editor, but you can useonAfterEditStop event to apply the same changes to the needed attribute.

    Here's an example for a single data key: https://webix.com/snippet/68f704e2

    And for the entire object: https://webix.com/snippet/4671acd1

    Please note the options definition: in the first sample, options:["1", "2"] will be initialized as a simple hash of options (available in event handler as editor.config.options), while an array of objects with a key-value pair will result in a full-featured column collection.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion