Uncaught Unknown file id xx in table yy
Uncaught Unknown file id xx in table yy
Hi Allan, hi community,
I do have a problem with FILE Upload.
Using Editor Version 2.0.5
I use File upload with a single file.
I have a table "medien" with an primary key for the fileId.
I have a sub table "v_arten" with a foreign key.
When I try to upload a file,
and press "upload"
the file is copied to the prospected file.
the dataset is written to the table "medien".
but the error "Uncaught Unknown file id xx in table yy" occurs.
if i press "save" again an then leave the pop-up dialog - the foreign key is written in the tabel "v_arten".
IF i press "cancel" it wont.
The dialog does not finish - you have to cancel it.
The "save" button changes to "processing" and will stay like this producing the error again and again.
Here is what I have in the javascript datatables definition:
var table = $('#example).DataTable( {
ajax: { url: 'dt-e.v_arten.php' } ,
columns: [
.. more columns ... only excerpt ..
{
data: "v_arten.idFMedien",
render: function ( fileId ) {
return fileId ?
'<img src="'+table.file( 'medien', fileId ).webPath+'" height="85px"/>' :
'No image';
},
defaultContent: "kein Bild",
title: "Bild"
}
(..)
],
select: true,
select: {
style: 'os'
},
buttons: [
{ extend: "create", className: "create",
editor: editor,
formButtons: [
'Speichern',
{ text: 'Abbrechen', action: function () { this.close(); } }
]
},
{ extend: "edit", className: "edit",
editor: editor ,
formButtons: [
'Speichern',
{ text: 'Abbrechen', action: function () { this.close(); } }
]
},
{
extend: "remove", className: "delete",
editor: editor,
formButtons: [
'Ja, Eintrag löschen',
{ text: 'Nein danke', action: function () { this.close(); } }
]
},
],
(the coding ist longer - i shortened it )
And here the editor definition:
var editor = new $.fn.dataTable.Editor( {
ajax: { url: 'dt-e.v_arten.php'
} ,
table: "#example",
i18n: {
create: {
button: "Neu",
title: "Neuer Eintrag",
submit: "neu"
},
edit: {
button: "Bearbeiten",
title: "Eintrag bearbeiten",
submit: "Speichern"
},
remove: {
button: "Löschen",
title: "Löschen",
submit: "Löschen",
confirm: {
_: "Sollen wirklich %d Zeilen unwiderruflich und komplett gelöscht werden?",
1: "Soll wirklich ein %d Eintrag unwiderruflich und komplett gelöscht werden?"
}
},
error: {
system: "Ein Fehler ist aufgetreten."
},
datetime: {
months: [ 'Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember' ],
weekdays: ['So', 'Mo', 'Di', 'Mi','Do', 'Fr', 'Sa' ],
}
},
fields: [
{
label: "Bezeichnung:",
name: "v_arten.Bezeichnung"
}
, {
label: "Beschreibung:",
name: "v_arten.Beschreibung",
type: "textarea"
}
,
{
label : "Startseite:",
name : "v_arten.AnzeigeStartseite",
type : "checkbox",
separator : "|",
unselectedValue: 0,
options : [{ label: "", value: 1 }]
}
, {
label: "Reihenfolge:",
name: "v_arten.ReihenfolgeStartseite"
}
,
{
label: "Bild: 180px x 120px ",
name: "v_arten.idFMedien",
type: "upload",
display: function ( fileId ) {
return '<img src="'+table.file( 'medien', fileId ).webPath+'"/>';
},
uploadText: "Durchsuchen ..",
clearText: "Entfernen",
dragDropText: "Datei hierher ziehen ...",
noImageText: 'Kein Bild'
}] ,
} );
And here an excerpt of the PHP:
```
<?php
include( $dt_lib."DataTables.php" );
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Mjoin,
DataTables\Editor\Options,
DataTables\Editor\Upload,
DataTables\Editor\Validate,
DataTables\Editor\ValidateOptions;
$out = Editor::inst( $db, 'v_arten' , 'v_arten.idVArt')
->fields(
Field::inst( 'v_arten.idVArt' ) ->set(false), //ID is automatically set by the database on create
Field::inst( 'v_arten.Bezeichnung' )
->validator( Validate::notEmpty( ValidateOptions::inst()
->message( 'Bitte eine Bezeichnung eintragen' )
) ),
Field::inst( 'v_arten.Beschreibung' )
->validator( Validate::notEmpty( ValidateOptions::inst()
->message( 'Bitte eine Beschreibung eintragen' )
) ) ,
Field::inst( 'v_arten.AnzeigeStartseite' ) ,
Field::inst( 'v_arten.ReihenfolgeStartseite' ) ,
Field::inst( 'v_arten.Bildname' ),
Field::inst( 'v_arten.idFMedien' )
// ->setFormatter( Format::ifEmpty( null ) )
->setFormatter( 'Format::nullEmpty' )
->upload( Upload::inst( $_SERVER['DOCUMENT_ROOT'].$_SESSION['root'].'/uploads/system/v_arten/ID.NAME' )
->db( 'medien', 'idMedien', array(
'fileName' => Upload::DB_FILE_NAME,
'fileSize' => Upload::DB_FILE_SIZE,
'webPath' => Upload::DB_WEB_PATH,
'systemPath' => Upload::DB_SYSTEM_PATH ,
'AufnahmeUser' => $_SESSION['USER'],
'AenderungsUser' => $_SESSION['USER'],
'AenderungsDatum' => date("Y-m-d H:i:s")
) )
->validator( Validate::fileSize( 500000, 'Bilder müssen kleiner sein als 500K' ) )
->validator( Validate::fileExtensions( array( 'png', 'jpg', 'jpeg', 'gif' ), "Nur Bilder können hochgladen werden (*.png, *.jpg, *.jpeg, *.gif)" ) )
->dbClean( function ( $data ) {
// Remove the file from the file system
unlink($data[0]['systemPath'] );
return true;
} )
)
,
Field::inst( 'v_arten.AenderungsDatum' )->set( Field::SET_EDIT ),
Field::inst( 'v_arten.AenderungsUser' ) ->set( Field::SET_EDIT ),
Field::inst( 'v_arten.AufnahmeUser' )->set( Field::SET_CREATE )
)
->on( 'preEdit', function ( $editor, $id, $values ) {
$editor
->field( 'v_arten.AenderungsDatum' )
->setValue( date("Y-m-d H:i:s") );
$editor
->field( 'v_arten.AenderungsUser' )
->setValue( $_SESSION['USER'] );
} )
->on( 'preCreate', function ( $editor, $values ) {
$editor
->field( 'v_arten.AufnahmeUser' )
->setValue( $_SESSION['USER'] );
} )
->debug(true)
->process( $_POST )
->json();
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:
This question has accepted answers - jump to:
Answers
I am sorry, i was too fast with publishing.
Just wanted to ask whether anybody can give me a hint.
And some regards, Monika.
Hi,
sorry - there is one more thing to say:
It worked with former Edition of Datatables 1.10.16 and the
Editor Version 1.7.4.
Now I use Datatables 1.11.3 and Editor 2.0.5
Regards, Monika.
Hi all,
here is more information, maybe it helps:
Uncaught Unknown file id 242 in table medien datatables.editor.min.js:41:72
Should be this function:
More ..
the marked codeline here is the line with the return statement.
Should I provide more information?
Is the description of the error understandable?
Thanks and greetings, Monika
Hi,
Thanks for all the details. One more thing - could you let me know what the JSON return from the server is when the data for the page is loaded please? (i.e. the return from
dt-e.v_arten.php
)?Thanks,
Allan
Hi Allan,
thanks for your answer.
here is the json repsonse:
Best regards, Monika.
Hi Allan,
... and here the not formatted version - i just realized, that there is more information concerning the bindings.
That's it
again regards, Monika.
That should have found the file id 243 inside the
medien
table. Can you show me the exact error message text (including the table name and id) please? Obviously the id will change, but that's okay. Perhaps you could show me the JSON for for you show me the error message as well, so both are in-sync.Thanks,
Allan
Hi Allan,
I am sorry, now I do not understand what I should send.
I try:
1. error message : The only message I can see is "uncaught unknown file in id xx in table medien." The editor dialog does not show an error message. I see only the caption "Processing" on the save-Button.
2. Where can I find the information you need to have? The name of the table and insert / select statements I sent in my last post. But it seems you expected somethin different?
Regards, Monika.
oh, is it the loading statements that you need?
I try :
Thanks. Monika.
I'm wondering specifically what the id is? Is it the same as the id in the returned JSON from the upload action?
If you could give me a link to your page that would be really useful as I can debug this live and hopefully save the back and forth.
Allan
Hi Allan,
the id of the table "medien" is idMedien.
the id of the table "v_arten" ist idVArt and the relevant foreign key ist "idFMedien".
I wonder how I can grant you access.
You have to login with .htaccess and a super-admin account.
How can I send these Login-information in a more protected manner?
Monika.
Sorry, i an not native speeking. Sometimes it takes some time to understand what you tell me.
id xx >> that "xx" is a placeholder >> whenever I test it, there will be the next id after a new insert.
in this case it was id 247.
Monika.
If you could drop me a private message with the login details that would be perfect. Click my forum user name above and then the "Send message" button.
Thanks!
Allan
Hi Allan,
I dropped a message. Hope you found it.
Thanks. Monika.
Hi Monika,
Many thanks and apologies for my delayed reply. I've released what is going wrong thanks to your link. The page has two copies of Editor being loaded in
datatables.min.js
datatables.editor.min.js
Remove that second one and it should work!
The error comes about because there are two different objects for storing the files, and the references are getting mixed up between the two blocks of code being loaded.
Allan
Hi Allan,
first of all - that was the error!
Thank you so much. I would have overlooked that for ages. I have downloaded the datatables-libraries so many times that I obviously added the editor last time and was not aware of that. So simple (when you look at it) and so much time spent on it.
Thank you once again for your friendly and persistent support and for this solution.
Best regads, Monika.
Delighted to hear that we got it sorted in the end
Allan
Indeed. You made my day. Monika.
Great Allan!I have had the same problem. Fixed!