Mjoin and child rows

Mjoin and child rows

AbominateAbominate Posts: 3Questions: 1Answers: 0

Debugger code (debug.datatables.net): esuqap
Error messages shown: 500
Description of problem:
I'm trying to replicate https://datatables.net/blog/2019-01-11#Parent-table with my own table.
I have two tables, master_file and consignment.
master_file's primary key is UniqueNo

consignment's primary key is Csm_Id
and is linked through it's own UniqueNo foreign key field to master_file

I'm trying to have the parent as master_file
and the child table as the list of Csm_Id's associated with that UniqueNo field.

The parent table is showing fine. However the child table is throwing a 500 error. I'm unable to check the error logs as I don't have access to that machine.

Parent:

Editor::inst( $db, 'master_file', 'UniqueNo' )
    ->fields(
        Field::inst( 'UniqueNo' )
    )
    ->join(
        Mjoin::inst( 'consignment' )
            ->link( 'master_file.UniqueNo', 'consignment.UniqueNo' )
            ->fields(
                Field::inst( 'Csm_Id' )
            )
    )
    ->where( 'master_file.Csm_ConsigneeCode', '460' )

    ->process( $_POST )
    ->json();

Child:

if ( ! isset($_POST['UniqueNo'])  ) {
    echo json_encode( [ "data" => [] ] );
}
else {
    Editor::inst( $db, 'consignment', 'Csm_Id' )
        ->field(
            Field::inst( 'consignment.UniqueNo' ),
            Field::inst( 'consignment.Csm_Id' ),
            Field::inst( 'master_file.UniqueNo' )
        )
        ->leftJoin( 'master_file', 'master_file.UniqueNo', '=', 'consignment.UniqueNo' )
        ->where( 'consignment.UniqueNo', $_POST['UniqueNo'] )
        ->process($_POST)
        ->json();
}

Answers

  • AbominateAbominate Posts: 3Questions: 1Answers: 0

    It's returning to correct # in the second parent column.

    Yet when I attempt to open the file:

  • AbominateAbominate Posts: 3Questions: 1Answers: 0

    I've fixed the issue. I simply removed the if(){}else{}
    section from the child's php.

    Any reason why this isn't coming through as true?

  • allanallan Posts: 63,213Questions: 1Answers: 10,415 Site admin

    Can you show me the client-side Javascript code you are using please? My guess is that the ajax.type option isn't set to POST for your child table, but it could be that UniqueNo just isn't being read or set correctly as well.

    Allan

This discussion has been closed.