Modify primary key via Editor

Modify primary key via Editor

unibocconi-ltccunibocconi-ltcc Posts: 14Questions: 4Answers: 0

Hi,
we have an Editor licence (PHP server side). I'm trying to create an app where I can edit the primary key of a table (it's not the standard auto incremental id, but a varchar string meaningful for the application). I tried several approaches by the usual error is **DataTables warning: table id=BB_CONF_CDS - Requested unknown parameter '0' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4**

Server Side code:

Editor::inst( $db, 'bb_conf_cds','TEMPLATE_COURSE_KEY' )
    ->fields(
        Field::inst( 'TEMPLATE_COURSE_KEY', 'alias' ),
        Field::inst( 'TERM_KEY' )
    )
    ->process( $_POST )
    ->json();

Client side JS

            $(document).ready(function() {
                var editor = new $.fn.dataTable.Editor( {
                    ajax: 'ws-mariadb.php',
                    table: '#BB_CONF_CDS',
                } );

                var table = $('#BB_CONF_CDS').DataTable( {
                    dom: 'Bfrtip',
                    ajax: 'ws-mariadb.php',
                    select: true,
                    lengthChange: false,
                    buttons: [
                        { extend: 'create', editor: editor },
                        { extend: 'edit',   editor: editor },
                        { extend: 'remove', editor: editor }
                    ]
                } );
            } );

HTML

    <table cellpadding="0" cellspacing="0" border="0" class="display" id="BB_CONF_CDS" width="100%">
        <thead>
        <tr>
            <th>TEMPLATE_COURSE_KEY</th>
            <th>TERM_KEY</th>
        </tr>
        </thead>
    </table>

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,344Questions: 26Answers: 4,954

    What is going on when the error occurs?

    Have you followed the troubleshooting steps provide at the link in the error?
    http://datatables.net/tn/4

    Let us know what you find.

    Kevin

  • allanallan Posts: 63,541Questions: 1Answers: 10,476 Site admin

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

    Thanks,
    Allan

  • unibocconi-ltccunibocconi-ltcc Posts: 14Questions: 4Answers: 0

    I found the issue, not clear why but in the JS snippet I had to declare the column names used both for the editor and the datatable.

    Why I cannot skip this declaration? Basically now if I need to add a column this needs to be configured in 4 places (PHP, HTML, 2 times in JS).

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    Both DataTables and Editor need to know how to map the columns to the data, so that's why they need to be declared.

    Colin

Sign In or Register to comment.