Created row not transferred back to the table (compound key), thus datatable not refreshed correctly
Created row not transferred back to the table (compound key), thus datatable not refreshed correctly
Hello,
I am struggling a bit with refreshing datatable after new row is created through the form.
DB table has 3 primary keys, so I am using compound keys with additional where statements:
Editor::inst( $db, 'ppe', array('id', 'id_projektu', 'id_firmy'))
->fields(
Field::inst( 'id' )->set( Field::SET_CREATE ),
Field::inst( 'id_projektu' )->setValue($_SESSION['id_projektu']),
Field::inst( 'id_firmy' )->setValue($_SESSION['id_firmy']),
...
})
->where( 'id_projektu', $_SESSION['id_projektu'] )
->where( 'id_firmy', $_SESSION['id_firmy'] )
->debug(true)
->process( $_POST )
->json();
After user presses Create button the row data is saved correctly in DB.
However, that data is not transffered back to the datatable - new row is not displayed.
I have checked, if postCreate event is triggered in front-end, but it's not (because of no data most probably).
The response I get in the browser is as follows:
0: {name: ":where_0", value: "1", type: null}
1: {name: ":where_1", value: "1", type: null}
2: {name: ":where_2", value: "", type: null}
3: {name: ":where_3", value: "", type: null}
4: {name: ":where_4", value: "", type: null}
query: "SELECT `id` as 'id', `id_projektu` as 'id_projektu', `id_firmy` as 'id_firmy', ... WHERE `id_projektu` = :where_0 AND `id_firmy` = :where_1 AND `id` = :where_2 AND `id_projektu` = :where_3 AND `id_firmy` = :where_4 "
I wonder why those 3 extra where commands are added to the query?
Why their values are set to empty strings?
I would like to add here that I want to display new row, without refreshing whole table - if possible ...
Thank you for answer.
This question has an accepted answers - jump to answer
Answers
Hi,
Thanks for the question. Could you show me all of the raw JSON that the server responds with to the new row form submission please? I've got a feeling that the setValue isn't being used as part of the query for retrieval, but I'd like to check that.
Thanks,
Allan
Hello Allan,
This is JSON I am getting as a response after pressing Create button:
Thank you for your answer,
Marek
HI Marek,
Sorry for the delay in getting back to you here. I've not had a chance to dig into this properly yet, but will post back as soon as I can.
Allan
Hi Marek,
The problem is here where
$values
are the values submitted from the client-side - which does not include the values set bysetValue
.I'll try to address this tomorrow - if not, I've got a workaround we could use in the short term using
onCreate
and modifying the array of values that was submitted.Regards,
Allan
Here we go. If you copy that change into your local copy of the Editor.php file, that should do the job!
Regards,
Allan
Hello Allan,
Works fine! Thank you for a fix.
Regards,
Marek