I'm so close!!! I almost have this functioning 100%, lol. I have 3 days left on my trial.
I'm implementing an inline editor with a field with type=select for the "Policy Type" field with a simple list of options.
Everything about it appears to be working fine .... except that it is not saving back to the table after the selection has been submitted.
My code:
var editor; // use a global for the submit and return data rendering in the examples
$(document).ready(function() {
editor = new $.fn.dataTable.Editor( {
ajax: window.location.pathname,
table: "#commissionschedule",
bProcessing: true,
bServerSide: true,
fields: [
{
label: "PlanID:",
name: "EID"
}, {
label: "Commission Type:",
name: "CommissionTypeID"
}, {
label: "Policy Type:",
name: "PolicyTypeName",
editField: "PolicyTypeID",
type: "select",
ipOpts: [{ "label": "1-Life", "value": "1" },
{ "label": "2-Annuity", "value": "2"}] ,
}, {
label: "Commission%:",
name: "CommPct"
}, {
label: "Target%:",
name: "Target"
}
]
} );
// Activate an inline edit on click of a table cell
$('#commissionschedule').on( 'click', 'tbody td:not(:first-child)', function (e) {
editor.inline( this, {
buttons: { label: '>', fn: function () { this.submit(); } }
} );
} );
$('#commissionschedule').DataTable( {
dom: "Tfrtip",
ajax: "php/processListObj.php?list=commissionschedule&has_form=false",
bProcessing: true,
bServerSide: true,
"pageLength": 25,
"lengthMenu": [25, 50, 75, 100 ],
columns: [
{ data: null, defaultContent: '', orderable: false },
{ data: "EID" },
{ data: "CommissionTypeID" },
{ data: "PolicyTypeName", editField: "PolicyTypeID" },
{ data: "CommPct" },
{ data: "Target" }
],
order: [ 1, 'asc' ],
tableTools: {
sRowSelect: "os",
sRowSelector: 'td:first-child',
aButtons: [
{ sExtends: "editor_create", editor: editor },
{ sExtends: "editor_edit", editor: editor },
{ sExtends: "editor_remove", editor: editor }
]
}
} );
} );
My server script:
<?php
Editor::inst( $db, 'qrycommissionschedule', 'CommissionScheduleID' )
->fields(
Field::inst( 'EID' )->validator( 'Validate::notEmpty' ),
Field::inst( 'CommissionTypeID' )->validator( 'Validate::notEmpty' ),
Field::inst( 'PolicyTypeID' )->validator( 'Validate::notEmpty' ),
Field::inst( 'CommPct' )->validator( 'Validate::numeric' ),
Field::inst( 'Target' )->validator( 'Validate::numeric' )
)
->process( $_POST )
->json();