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

Editor datatable field - how to use data from the row?

$
0
0

My table data looks like so:

[
    {
        "Id": 1,
        "Name": "Parent 1",
        "Children": [ { "Id": 1, "Name", "Bob" }, { "Id": 2, "Name", "Alice" } ]
    },
    {
        "Id": 2,
        "Name": "Parent 2",
        "Children": [ { "Id": 3, "Name", "Jane" }, { "Id": 2, "Name", "Alice" } ]
    },
]

I am trying and failing to display this as read only info in my table:

 var editor = new $.fn.dataTable.Editor({
     // ...
     fields: [
         {
             "name": "Name",
             "label": "Name",
         },
         {
             label: 'Children:',
             name: 'Children',
             type: 'datatable',
             config: {
                 columns: [
                     {
                         title: 'Id',
                         data: 'Id'
                     },
                     {
                         title: 'Name',
                         data: 'Name'
                     }
                 ]
             }
         },

I have read the docs and I assume Editor is looking for my data in the "options" server-side payload. If I wanted to provide this data I could use config.data I assume, but I am not sure how to supply it with the selected table row as I dont have access to the table instance at that time either. I cant seem to find any options that take a function that give me the editor data and the table API.


Viewing all articles
Browse latest Browse all 3744