Form with datatable does not load table data from nested json

Method form.load loads element values of the form mapping to json names except datatable.

json example:
{ "plan": false,
"details": [{"value": 100},
{"value": 300}
]
}

Of course it is possible to load it after like ($$('details') is datatable)

  $$('editform').load(elementUrl + "/" + id).then(function(data){
      data = data.json();
      $$('details').parse(data.details);
  });

But it would be nice if loading will work right out of the box.

Thank you.

Comments

  • Hello, @Mika

    If you want to use datatable as a form simple control, you need to define the setValue and getValue methods for the datatable, i.e. to create a custom component:

    webix.protoUI({
        name:"formtable",
        $allowsClear:true,     // reflect to form.clearAll()
        setValue:function(value){ . . . },
        getValue:function(){ . . .  }
    }, webix.ui.datatable);
    

    A very common use-case is setting/getting the selection:

    http://webix.com/snippet/01e7064d

    In case of data loading the methods should be configured as follows:

    http://webix.com/snippet/e9eb4b0c

    Besides, you still can load the data using the id of the particular component.

  • Hello, Alena,

    It works, thank you!

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