Select2 Filtered Row Won't Edit
Select2 Filtered Row Won't Edit
in Editor
Hi Allan,
I want to filter row using select2, then edit field value from selected row using editor edit button.
My problem is, the value won't updated
I load the ajax using
data: function ( d ) {
d.kode_distro = $("#SelectDistro").val();
}
where kode_distro is a selected value from select2
then on my php file
if ( ! isset($_POST['kode_distro']) || ! is_numeric($_POST['kode_distro']) ) {
echo json_encode( [ "data" => [] ] );
}
else {
Editor::inst( $db, 'tr_receiving_detail' )
->pkey('tr_receiving_detail.id')
->fields(
Field::inst( 'tr_receiving_head.tr_in_id' ),
Field::inst( 'tr_receiving_detail.id' ),
Field::inst( 'tr_receiving_detail.item_code' )
->options( 'master_item', 'item_code', 'item_name', function ($q) {
$q->where( 'axapta', 'No', 'LIKE' );
}),
Field::inst( 'master_item.item_name' ),
Field::inst( 'tr_receiving_detail.quantity' ),
Field::inst( 'tr_receiving_detail.customer_id' )
->options( 'master_customer', 'id', 'customer_name' ),
Field::inst( 'master_customer.customer_name' ),
Field::inst( 'tr_receiving_detail.enduser_code' ),
Field::inst( 'tr_receiving_detail.enduser_name' ),
Field::inst( 'tr_receiving_detail.changes' ),
Field::inst( 'tr_receiving_detail.dom_no' ),
Field::inst( 'tr_receiving_detail.old_id' ),
Field::inst( 'tr_receiving_detail.tr_in_id' )
)
->leftJoin( 'tr_receiving_head', 'tr_receiving_head.tr_in_id', '=', 'tr_receiving_detail.tr_in_id' )
->leftJoin( 'master_item', 'master_item.item_code', '=', 'tr_receiving_detail.item_code' )
->leftJoin( 'master_customer', 'master_customer.id', '=', 'tr_receiving_detail.customer_id' )
//where semua field lengkap (nama distro, nama bengkel & belum kirim)
//kalo belum engkap keisi semua, harus pake update
->where ('tr_receiving_detail.psm_no','')
->where ('tr_receiving_detail.changes',0)
->where ( 'tr_receiving_detail.customer_id', '', '<>' )
->where ( 'tr_receiving_detail.enduser_code', '', '<>' )
->where ( 'tr_receiving_detail.enduser_name', '', '<>' )
->where( 'tr_receiving_detail.customer_id', $_POST['kode_distro'] )
->process($_POST)
->json();
}
Live site here
Please advise, thank you
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
is currently be undefined when you submit the edit. You need to define that in the
ajax.dataoption as well as the DataTables one (or modify the PHP to not attempt to use it for editing).Allan
I try this, but no luck. The
ajax.datais same as the ajax.data on datatables, which works good with select2 filter. Please adviseIf I pick "Lebron James" in the select2 list and then edit the first row in the table, this is what is sent to the server:
I don't see the
ajax.dataoption in the code:Have a look at the
ajax.datadocumentation for how it should work - it is nested in theajaxoption.Allan
ah my bad, sorry Allan, i didn't change the live site, i change my localhost only.
Now i put the same code as i wrote above, please take a look.
thank you
I think you missed this part of my comment above:
Your
dataoption isn't doing anything in the Editor configuration at the moment.Allan
hello Allan,
thank you for the explanation, i create a different php file for the editor and it works.
So i'm using 2 different php file for datatables and editor
I'm not sure this is the correct / best solution, but it's ok for now, thanks again
danny
Its a perfectly valid thing to do and it can be quite useful. Good to hear you have it working.
Allan