Where condition in php script don't work /solved/ and how I can reload table with new condition
Where condition in php script don't work /solved/ and how I can reload table with new condition
I want use additonal condition for my selected data with ->where
and I send variable $cur_id
for this. I have read forum and found this topic https://datatables.net/forums/discussion/25876/join-tables-displaying-single-value-from-second-table#latest
Edited:
This is solved. But I can`t reload table after condition was changed.
This is my code:
include( "lib/DataTables.php" );
// Alias Editor classes so they are easy to use
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Join,
DataTables\Editor\Upload,
DataTables\Editor\Validate;
$cur_id=$_GET['my_id'];
Editor::inst( $db, 'modx_vkrzakaz','id' )
->fields(
Field::inst( 'modx_vkrzakaz.no_zak' ) ,
Field::inst( 'modx_vkrzakaz.kli_zak' )
->options( 'modx_vkrklient', 'id', 'fio' ),
Field::inst( 'modx_vkrklient.fio' ),
Field::inst( 'modx_vkrzakaz.avt_zak' )
->options( 'modx_vkravtor', 'id', 'name' ),
Field::inst( 'modx_vkravtor.name' ),
Field::inst( 'modx_vkrzakaz.vid_zak' )
->options( 'modx_vkrvidzak', 'id', 'vidname' ),
Field::inst( 'modx_vkrvidzak.vidname' ),
Field::inst( 'modx_vkrzakaz.is_step1' ),
Field::inst( 'modx_vkrzakaz.is_step2' ),
Field::inst( 'modx_vkrzakaz.is_step3' ),
Field::inst( 'modx_vkrzakaz.is_step4' ),
Field::inst( 'modx_vkrzakaz.is_step5' ),
Field::inst( 'modx_vkrzakaz.is_step6' ),
Field::inst( 'modx_vkrzakaz.is_step7' ),
Field::inst( 'modx_vkrzakaz.tema_zak' ),
Field::inst( 'modx_vkrzakaz.predpr_zak' ),
Field::inst( 'modx_vkrzakaz.srok_zak' )
->validator( 'Validate::dateFormat', array(
"empty" => false,
"format" => Format::DATE_ISO_8601,
"message" => "Введите дату в формате гггг-мм-дд"
) )
->getFormatter( 'Format::date_sql_to_format', Format::DATE_ISO_8601 )
->setFormatter( 'Format::date_format_to_sql', Format::DATE_ISO_8601 ),
Field::inst( 'modx_vkrzakaz.sum' ),
Field::inst( 'modx_vkrzakaz.sum_opl' ),
Field::inst( 'modx_vkrzakaz.priority' ),
Field::inst( 'modx_vkrzakaz.avt_list' )
)
->where( function ( $q ) use ( $cur_id ) {
$q->where('modx_vkrzakaz.avt_zak',$cur_id);
} )
->leftJoin( 'modx_vkrklient','modx_vkrklient.id', '=', 'modx_vkrzakaz.kli_zak' )
->leftJoin( 'modx_vkravtor' ,'modx_vkravtor.id' , '=', 'modx_vkrzakaz.avt_zak' )
->leftJoin( 'modx_vkrvidzak','modx_vkrvidzak.id', '=', 'modx_vkrzakaz.vid_zak' )
->process( $_POST )
->json();
This discussion has been closed.
Replies
I have test variant with constant in condition.
It`s work clear.
Solved:
I used unnecessary quotation marks in script parameter string).This is the right way:
Next related problem found:
I select
my_id
variable on Bootstrap new tab selected andI want update table data after
my_id
changed, testing this code:Event is work, but table not reload data.
Find this topic https://www.datatables.net/forums/discussion/30286/ajax-reload-is-not-sending-updated-params
Test using
ajax.data
Yes!)
Than I use
ajax.data
, this codealways reload table.
I changed my table definition:
and edit
table.modx_vkrzakaz_var.php
:My problem is completely solved.
Thanks, Allan.
Hi,
Nice monologue ;-). Good to hear that you have resolved the issue now. It looks like your solutions are exactly what I would have suggested.
Regards,
Allan
Hi, Allan.
Yes, I use your advice from this topic:
https://www.datatables.net/forums/discussion/30286/ajax-reload-is-not-sending-updated-params
Thank you for advice.
Vitaliy.