Creating a parent/child datatable page

Creating a parent/child datatable page

nessinitsnessinits Posts: 86Questions: 27Answers: 0

Hi all,

I'm new at this and I'm trying to follow the blog about the parent/child datatable example.

I've altered the existing datatable, editor and .php, so that's setted up. Now I'm trying to simply make a logic change to the variable names and from now on it stopped working. just by making editor employeeeditor it stops. I can understand that these variables are used somewhere else in the code. But where?

Does anyone know how to help me?

Kind regards,
nessinits

Replies

  • kthorngrenkthorngren Posts: 21,570Questions: 26Answers: 4,996

    We would need to see your code to understand the problem. Can you post a link to it or post it here for review?

    Kevin

  • nessinitsnessinits Posts: 86Questions: 27Answers: 0
    edited March 2017

    The HTML

                <table cellpadding="0" cellspacing="0" border="0" class="display" id="employee" width="100%">
                    <thead>
                        <tr>
                            <th>Naam</th>
                            <th>Roepnaam</th>
                            <th>Telefoon</th>
                            <th>e-mail</th>
                            <th>BSN</th>
                        </tr>
                    </thead>
                </table>
    
                <table cellpadding="0" cellspacing="0" border="0" class="display" id="address" width="100%">
                    <thead>
                        <tr>
                            <th>Straat</th>
                        </tr>
                    </thead>
                </table>
    
    
    
  • nessinitsnessinits Posts: 86Questions: 27Answers: 0
    edited March 2017

    All files have been generated by the datatable and editor generator, but have been slightly adjusted afterwards.

  • nessinitsnessinits Posts: 86Questions: 27Answers: 0
    edited March 2017

    The php

    <?php
    
    /*
     * Editor server script for DB table employee
     * Created by http://editor.datatables.net/generator
     */
    
    // DataTables PHP library and database connection
    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\Mjoin,
        DataTables\Editor\Options,
        DataTables\Editor\Upload,
        DataTables\Editor\Validate;
    
    // Build our Editor instance and process the data coming from _POST
    Editor::inst( $db, 'employee')
       ->pkey('id')
       ->fields(
            Field::inst( 'employee_id' ),
            Field::inst( 'lastname' )->validator( 'Validate::notEmpty' ),
            Field::inst( 'prefix' ),
            Field::inst( 'firstname' )->validator( 'Validate::notEmpty' ),
            Field::inst( 'givenname' )->validator( 'Validate::notEmpty' ),
            Field::inst( 'phone' )->validator( 'Validate::notEmpty' ),
            Field::inst( 'email' )->validator( 'Validate::notEmpty' )
                ->validator('Validate::unique'),
            Field::inst( 'bsn' )->validator( 'Validate::notEmpty' )
                ->validator('Validate::unique'),
            Field::inst( 'birthdate' )->validator( 'Validate::notEmpty' )            
                ->validator( 'Validate::dateFormat', array(
                    "format"  => Format::DATE_ISO_8601,
                    "message" => "Please enter a date in the format yyyy-mm-dd"
                ) )
                ->getFormatter( 'Format::date_sql_to_format', Format::DATE_ISO_8601 )
                ->setFormatter( 'Format::date_format_to_sql', Format::DATE_ISO_8601 ),
            Field::inst( 'birthplace' )->validator( 'Validate::notEmpty' ),
            Field::inst( 'employable' ),
            Field::inst( 'active' ),
            Field::inst( 'internal' )
        )
        ->join(
            Mjoin::inst( 'address' )
                ->link( 'employee.employee_id', 'address.foreign_id' )
                ->fields(
                    Field::inst( 'street' )
                )
            )
        ->process( $_POST )
        ->json();
        
    
  • kthorngrenkthorngren Posts: 21,570Questions: 26Answers: 4,996

    The JS code showing the parent and child Datatables and Editor code is needed. I assume thats where you made the variable name change to employeeeditor.

    Also please describe specifically what the problem is.

    Kevin

  • nessinitsnessinits Posts: 86Questions: 27Answers: 0

    Thanks for thinking with me. I've solved the issue. I forgot to rename the new, edit and delete buttons to the same variable.

This discussion has been closed.