Quantcast
Channel: Editor — DataTables forums
Viewing all articles
Browse latest Browse all 3800

Editor 2 nested editing

$
0
0

I'm hoping that the new datatable field type will allow for the following scenario, but if not it would be a nice feature to have.

I have a database table which contains a JSON field. Based on what I have seen, nested editing only seems to be for lookups where you can select either a single or multiple rows from a predefined list using the options attribute.

For example, a sample record below:

Id Company Offices
1 Acme Inc. [{"name":"New York","employees":12}, {"name":"Chicago","employees":5}, {"name":"Los Angeles","employees":3}]

I would like the main editor to be for company (with id as key), then a nested datatable for name and employees (from offices JSON). I don't think I can configure this out of the box, but would it be possible to achieve via custom code?

The data it would receive from the server would be the following:

[{"id":1,"company":"Acme Inc.","offices":[{"name":"New York","employees":12}, {"name":"Chicago","employees":6}, {"name":"Los Angeles","employees":3}]}]

And based on Client-to-server in documentation it would submit:

{"data":{"1":{"company":"Acme Inc.","offices":[{"name":"New York","employees":12}, {"name":"Chicago","employees":6}, {"name":"Los Angeles","employees":4}] }},"action":"edit"}

Is this something that is possible and if so, do you have an example? If not, is this something that can be done with Javascript using events? I guess this isn't the demonstrated use case, but it would be very useful to be able to do.


Viewing all articles
Browse latest Browse all 3800

Trending Articles