Editor - getting id of row from within fixedColumn
Editor - getting id of row from within fixedColumn
I have a fixed column (left and right) with an edit button in the right column. I also have inline edting - which works 100%.
All is well and the click on the button is fired but shows an empty modal rather than with fields in. I suspect that this is due to the way fixed columns work.
The 'create' button works 100% - so editor is configured fine.
Question: How to correctly obtain the row to edit from an edit link in a fixedColumn.
Debugger: http://debug.datatables.net/awemar
Code for the Editor:
editorBDM = new $.fn.dataTable.Editor( {
ajax: "/site_mods/bd/bd_fulllist_server.php",
table: "#bdmlist_1",
fields: [ {
label: "Agent Company Name:",
name: "agents.ag_name"
}, {
label: "Telephone Number:",
name: "agents.ag_tel"
}, {
label: "Primary Contact Name:",
name: "agents.ag_primary_contact"
}, {
label: "Email Address:",
name: "agents.ag_email"
}, {
label: "Agent Town:",
name: "agents.ag_town"
}, {
label: "Agent County:",
name: "agents.ag_county"
}, {
label: "Existing Notes:",
name: "agents.ag_notes"
}, {
label: "Record Status:",
name: "agents.ag_status"
}, {
label: "BDM Responsible:",
name: "agents.ag_bdm"
}, {
label: "Agents Website:",
name: "agents.ag_website"
}
]
} );
The event:
// Edit record
$('#bdmlist_1').on('click', 'a.editor_edit', function (e) {
e.preventDefault();
console.log($(this).closest('tr'));
editorBDM.edit( $(this).closest('tr'), {
title: 'Edit record',
buttons: 'Update'
} );
} );
The Inline activation: (which works 100%)
// Activate an inline edit on click of a table cell
$('#bdmlist_1').on( 'click', 'tbody td:not(:last-child)', function (e) {
editorBDM.inline(this,{
onBlur: 'submit'
});
} );
Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
Replies
To use FixedColumns with Editor you would need to use the
fixedColumns().rowIndex()
method to get the row index. You can then use that index to pass on to theedit()
orinline()
method to trigger editing.Allan
Hi Allan
Success!
I placed the following code in the click event function, which just for the sake of completeness I paste here.
Thanks for the syntax highlighting guidance on my utter fail at copy/paste :)