How to update the nested object while using multiple columns with colspan under a single column

edited December 6 in Technical questions

Hi,

In my datatable I have multiple editable columns under one parent column.
The data set is also having an array object to show values into those sub-columns.

However, whenever I change some values in those columns, the data set object is not getting updated properly. Instead it is creating another extra key-value pair within it.

Also inside the $init the mechanism to show the existing value in the cells is getting spoiled due to it.

For example for one row only the data set object when the table renders before any editing looks like below:

obj = {"No":"1","Name":"Justine","scores":[{"rank":2,"vote":"SF"}],"place":[{"type":"type1","name":"name1"}],"id":1512586172984}

Now if I edit the place_type column to some other place say, 'type1234', that gets added additionally to the data set as below:

obj = {"No":"1","Name":"Justine","scores":[{"rank":2,"vote":"SF"}],"place":[{"type":"type1","name":"name1"}],"id":1512586172984,"place_type":"type1234"}

The snippet is here https://webix.com/snippet/d5d2d19d
However for other plain editable columns like 'Name' it is not happening.
What is going wrong and how can it be solved ?

Thanks.

Tagged:

Comments

  • edited December 7

    Can anybody please comment on how it could be solved ? I have been trying with custom cell edit from https://docs.webix.com/datatable__editing.html#creatingcustomeditor , but no success and clue about it much.

    Further to above post using custom edit I have been able to change it by directly updating the JSON in the $ready block as soon as a cell value is edited.

    The snippet is here : https://webix.com/snippet/8d8f99ac

    However, in the actual scenario this JSON is much bigger and complex and different in every scenario.

    Is there an elegant way to achieve this ?

    Thanks.

  • Hi,

    Below way I have been able to get the result near to my requirement.
    Also I am able to retain the existing values in the cells when they are clicked.
    In the custom event function I am directly modifying the object and expliciltly deleting any extra key added to the object during $init.

    Snippet is here https://webix.com/snippet/58d9c7a7

    If anybody has a better solution to take care of this problem, kindly suggest.

    Thanks.

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