fnServerParams within Editor
fnServerParams within Editor
Hi All,
I have Parent - Child tables where I am using fnServerParams and reLoadAjax on the ParentTable to keep the relationship in synch. I am using fnServerParams to pass a value to the Child PHP file for a where clause (ie. where member_id = $member_key). These are fairly large tables ~5M rows. Everything is working great in dataTables. Any change of row in the Parent Table displays the appropriate subset of data in the child table. I can see the server parameter passed from fnServerParams in debug. Performance is very acceptable- ~30ms for each child table load.
Issue - generic updates to the Child Table via Editor are not seeing the server parameter member_key. The updates are actually getting through but the error is in the post back (I think). I am hoping (and expecting) that I am missing something really basic here.
if(isset($_POST['member_key'])){ $member_key = $_POST['member_key']; };
$out = $editor
->where( 'member_id', $member_key,'=' ) // error is here
->process($_POST)
->data();
Unfortunately I cannot provide a test at this time.
Any ideas?
Thanks in advance
I have Parent - Child tables where I am using fnServerParams and reLoadAjax on the ParentTable to keep the relationship in synch. I am using fnServerParams to pass a value to the Child PHP file for a where clause (ie. where member_id = $member_key). These are fairly large tables ~5M rows. Everything is working great in dataTables. Any change of row in the Parent Table displays the appropriate subset of data in the child table. I can see the server parameter passed from fnServerParams in debug. Performance is very acceptable- ~30ms for each child table load.
Issue - generic updates to the Child Table via Editor are not seeing the server parameter member_key. The updates are actually getting through but the error is in the post back (I think). I am hoping (and expecting) that I am missing something really basic here.
if(isset($_POST['member_key'])){ $member_key = $_POST['member_key']; };
$out = $editor
->where( 'member_id', $member_key,'=' ) // error is here
->process($_POST)
->data();
Unfortunately I cannot provide a test at this time.
Any ideas?
Thanks in advance
This discussion has been closed.
Replies
Editor doesn't share its Ajax options with DataTables at all, so if you want to send extra parameters you need to do it using the 'Editor way'. In this case, there are two options:
1. Listening for the `onPreSubmit` event ( https://editor.datatables.net/options/#onPreSubmit ):
[code]
editor.on( 'onPreSubmit', function ( d ) {
d.data.member_key = '...';
} );
[/code]
2. Using a hidden field: https://editor.datatables.net/fields/#hidden . You'd just set the value that you want the field to be.
Either method should work in this case I think - its whichever you prefer to use!
Allan
BTW, there is still an update bug 'Undefined offset: 0 in /datatables/lib/Editor/Editor.php'
that was referenced on the bottom of http://datatables.net/forums/discussion/comment/48995
however AKM3's fix is working fine.
Thanks again.
Does it say what line number it is? That error can occur if the primary key has changed value - at least that's when I've seen it occur myself.
Regards,
Allan
What I found was the actual problem was higher at row 521 '$res = $this->_db->update( $this->_table, $set, array($this->_pkey => $id) )'; which was failing a string conversion.
Again this occurred when using a where clause as in the following code snip. The commented code causes the error and the workaround is the current solution,.
// workaround to fix Editor where update issue - http://datatables.net/forums/discussion/comment/48995
if (!isset( $_POST['action'] )) $editor->where( 'member_id', $member_key,'=' );
$out = $editor
//->where( 'member_id', $member_key,'=' )
->process($_POST)
->data();
Hope this helps.
In this condition, would you expect the data to be removed form the table?
Allan