Blank editor window pops up.
Blank editor window pops up.
I cant show the site as it has customer info on there.
I use the following code to get data from various tables ( this is invoice data)
Each time it runs I get a editor window popup with no info just a update Invoice button
Any ideas what I am doing wrong to trigger this ?
Cheers
Steve Warby.
getInvoices=function(){
// check if customer already selected. If so dont run the query
if (currentCustID !== selectedCustID )
{
currentCustID = selectedCustID;
// create editor
editorInvoices = new $.fn.dataTable.Editor( {
ajax : {
'url' : 'http://www.xxx.com/php/xxxx.php',
"type": "POST",
"data": {
'selectedCustID': selectedCustID
}
},
table: "#dtInvoices",
//template: '#customForm',
fields: [
{
label: "Inv ID:",
name: "invoice.InvID"
},
{
label: "Del Type:",
name: "invoice.delMethod",
type: 'radio',
options: [
'Collected',
'Own Van',
'Hermes STD',
'Hermes Next Day',
'Other']},
{
label: "Pay Type:",
name: "invoice.payMethod",
type: 'radio',
options: [
'Cash',
'Cheque',
'Account',
'PayPal',
'Bacs',
'Card']
}, {
label: "Order Number:",
name: "invoice.orderNum"
}, {
label: "Notes",
name: "invoice.notes"
}, {
label: "Inv Date:",
name: "invoice.invDate"
}, {
label: "Pay Date:",
name: "invoice.payDate"
}
]
} );
editorInvoices.on('initEdit', function (val) {
editorInvoices.disable(["invoice.InvID"]);
});
editorInvoices.on('initCreate', function () {
//alert('on create ');
editorInvoices.set( 'CustID', selectedCustID );
editorInvoices.disable(["invoice.InvID"]);
});
editorInvoices.title('Edit entry').buttons('Update Invoice').edit(this);
// set the datatables up..........................................
$("#dtInvoices").DataTable().destroy();
$('#dtInvoices').empty();
tableInvoices = $('#dtInvoices').DataTable( {
scrollY: "200px",
scrollCollapse: true,
paging: false,
info: false,
select: true,
ordering: true,
order: [[0, 'desc']],
dom: "Bfrtip",
autoWidth : true,
responsive: true,
bSort:false,
// bServerSide: true,
ajax : {
'url' : 'http://www.xxx.com/php/xxx.php',
"type": "POST",
"data": {
'selectedCustID': selectedCustID
}
},
columns: [
{ data: "invoice.InvID" , responsivePriority: 2, title : 'Inv No'},
{ data: "invoice.delMethod" , responsivePriority: 2, title : 'Del Type'},
{ data: "invoice.payMethod" , responsivePriority: 2, title : 'pay Type'},
{ data: "invoice.invDate" , title : ' Inv Date'},
{ data: "invoice.payDate" , title : ' Pay Date'},
{ data: "invoice.invNett" , title : ' Nett'},
{ data: "invoice.invTax" , title : ' Vat'},
{ data: "invoice.invTotal" , title : ' Total'},
{ data: "invoice.orderNum" , title : ' Order Num'},
{ data: "invoice.notes" , title : ' Notes'},
{ data: "invoice.CustID" , title : ' Cust No'}
],
buttons: [
{ extend: "create", editor: editorInvoices },
{ extend: "edit", editor: editorInvoices },
{ text: "Refresh Details",
action: function (e, dt, node, config) {
getInvoices();}
}
]
// console.log('data returned = '+data);
} );
$('#dtInvoices').on( 'select.dt', function ( e, dt, type, indexes ) {
//var data = dt.rows(indexes).data();
selectedInvoiceID = tableInvoices.cell('.selected', 0).data();
console.log('selectedInvoiceID = '+ selectedInvoiceID);
} );
$('#dtInvoiceDetails_search').on( 'keyup', function () {
tableInvoiceDetails
.columns(6)
.search( this.value )
.draw();
} );
}
}
php
include( "DataTables.php" );
// Alias Editor classes so they are easy to use
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Mjoin,
DataTables\Editor\Options,
DataTables\Editor\Upload,
DataTables\Editor\Validate;
// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'invoice' , 'InvID')
->fields(
Field::inst( 'invoice.InvID' ),
Field::inst( 'invoice.CustID' ),
Field::inst( 'invoice.invDate' ),
Field::inst( 'invoice.payDate' ),
Field::inst( 'invoice.delMethod' ),
Field::inst( 'invoice.payMethod' ),
Field::inst( 'invoice.invNett' ),
Field::inst( 'invoice.invTax' ),
Field::inst( 'invoice.invTotal' ),
Field::inst( 'invoice.vatRate' ),
Field::inst( 'invoice.orderNum' ),
Field::inst( 'invoice.notes' )
)
->process( $_POST )
->json();
This discussion has been closed.
Answers
Bump on this guys.
Alan I can send a private link to show the problem if that helps.
Cheers
Steve Warby
Okay I have stripped down the app to just get one record in the database and no other datatables.
What am I doing wrong here ?
http://www.surplusanywhere.com/popupProblem
php code
client code
Found the issue
editorCustomer.title('Edit entry').buttons('Update Customer').edit(this);
removed '.edit(this);'
Dont know where I got that bit from.
Thanks for posting back. I'm not sure that line is actually doing much at all there - its better to set the title and buttons when the editing / creation is triggered.
Allan