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.
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.