Constantly getting error when trying to inline edit standalone table
Constantly getting error when trying to inline edit standalone table
Hi there,
i am using the current version oft Editor together with a stndalone table (in this case, NO DataTable). I followed this example, but getting the following error constantly:
Uncaught TypeError: Cannot read properties of undefined (reading 'attach')
My basic implementation is as follows:
HTML (part):
<table>
<tr>
<th>State:</th>
<td data-editor-field="enable">Enabled</td>
</tr>
<tr>
<th>Server IP:</th>
<td data-editor-field="server-ip">153.63.213.41</td>
</tr>
<tr>
<th>Poll period (seconds):</th>
<td data-editor-field="poll-period">60</td>
</tr>
<tr>
<th data-editor-label="protocol">Protocol:</th>
<td data-editor-field="protocol">TCP</td>
</tr>
</table>
I also tried using the dl-dd-dt structure used in the example, no difference.
Javascript (part):
let editor = new $.fn.dataTable.Editor({
ajax: null,
table: tableSelector,
fields: [{
label: "Status:",
name: "enable",
type: 'radio',
options: [
{label: 'Enabled', value: 'Enabled'},
{label: 'Disabled', value: 'Disabled'}
]
}, {
label: "Server IP address:",
name: "server-ip"
}, {
label: "Polling period:",
name: "poll-period"
}, {
name: "protocol", // `label` since `data-editor-label` is defined for this field
type: "select",
options: [
{label: 'TCP', value: 'TCP'},
{label: 'UDP', value: 'UDP'}
]
}
],
formOptions: {
inline: {
onBlur: 'submit'
},
submit: 'allIfChanged'
},
})
$('[data-editor-field]').on('click', function (e) {
editor.inline($(this).closest('tr'), {
buttons: '_basic'
});
});
I guess it is related to the first parameter of inline(), but I tried literally anything here, like:
this
$(this)
e.currentTarget
$(this).closest('tr)
As I said before, this certain case does NOT use a DataTables instance for the table part. In certain other cases, I use DataTables and Editor together and everything works fine.
Any help appreciated!
Frank
This question has an accepted answers - jump to answer
Answers
OK, my fault. I added the "table" attribute to the initialisation configuration by accident. Removing it, makes thing lot easier ;-)
Thanks for the update - good to hear you got it working.
Allan