Datatables as an input multiple selection loses selections in edit

Datatables as an input multiple selection loses selections in edit

GargiucnGargiucn Posts: 109Questions: 30Answers: 0

Datatables as an input multiple selection loses selections in edit.
I used datatables download builder with all features built in including jQuery and bootstrap4 in external files.
When I enter new values they are correctly stored in the table but when I go to edit no entries show up selected
Using checkboxes everything works perfectly...

<Editor>
{
  label: "Mansioni",
  name: "mansioni[].man_id",
  type: "datatable",
  multiple: true
},

<Table>
{
  data: "mansioni",
  render: "[, ].mansione.man_cod",
}   

<Php>
$editor->join(
    Mjoin::inst( 'mansioni' )
        ->link( 'dipendenti.dip_id', 'dipmans.dip_id' )
        ->link( 'mansioni.man_id', 'dipmans.man_id' )
        ->order( 'man_descr asc' )
        ->fields(
            Field::inst( 'man_id' )
                ->validator( Validate::required() )
                ->options( Options::inst()
                    ->table( 'mansioni' )
                    ->value( 'man_id' )
                    ->label( ['man_descr', 'man_cod'] )
                    ->where( function ($q) {
                        $q->where('mansioni.man_az', $_SESSION['azienda']);
                    } )
                    ->render( function ( $row ) {
                        return $row['man_descr'].' ('.$row['man_cod'].')';
                    } ) 
                ),
            Field::inst( 'man_descr' ), 
            Field::inst( 'man_cod' )
        )
);          

Any advice will be welcome!
Giuseppe

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,602Questions: 1Answers: 10,486 Site admin
    Answer ✓

    Hi Giuseppe,

    My guess is that the type of man_cod doesn't match the type of man_id. I'd guess that one is a string and the other is a number.

    Can you use the debugger to give me a trace please - click the Upload button and then let me know what the debug code is.

    Regards,
    Allan

Sign In or Register to comment.