Has anyone incorporated the softdelete example into the parentchild datatables example?
Has anyone incorporated the softdelete example into the parentchild datatables example?
I think this is due to the dynamic nature of the child datatables in the parentChild example.
Apologizes if this has been answered previously, but I did not find anything in the search.
The line in the below code that is the issue (I think) is ' var rows = DataTables_Table_0.rows({ selected: true }).indexes();' which does not work. I attempted using the ID from inspect since there is no obvious instantiation of the datatable in question (at least that I can see).
Any ideas?
Thanks in advance!
{ label: 'Users:', name: 'users.site', type: 'datatable', editor: usersEditor, submit: false, optionsPair: { value: 'users.id' }, config: { ajax: { url: '../controllers/NEWuser/users.php', type: 'post', data: function (d) { if (siteTable) { var selected = siteTable.row({ selected: true }); if (selected.any()) { d.site = selected.data().id; } } } }, buttons: [ { extend: 'create', editor: usersEditor }, { extend: 'edit', editor: usersEditor }, //{ extend: 'remove', editor: usersEditor } { extend: 'selected', text: 'Delete', action: function (e, dt, node, config) { var rows = DataTables_Table_0.rows({ selected: true }).indexes(); usersEditor .hide(usersEditor.fields()) .one('close', function () { setTimeout(function () { // Wait for animation usersEditor.show(usersEditor.fields()); }, 500); }) .edit(rows, { title: 'Delete', message: rows.length === 1 ? 'Are you sure you wish to delete this row?' : 'Are you sure you wish to delete these ' + rows.length + ' rows', buttons: 'Delete' }) .val( 'removed_date', new Date().toISOString().split('T')[0] ); } } ], columns: [ { data: 'users.first_name', title: 'First name' }, { data: 'users.last_name', title: 'Last name' }, { data: 'users.phone', title: 'Phone' } ] } }
Replies
Will create a DataTable itself (with the configuration options from
config).Do you want
var rows = DataTables_Table_0.rows({ selected: true }).to refer to the DataTable in the Editor field? If so use:i.e. Use the
dtparameter which is the DataTables instance for the button, which is passed into the button's event handler.Allan
Thanks Allan. I was hoping it was that straightforward.