Inline Editor not Loading Rows, Requested unkown parameter 'EID' for row 0.

Inline Editor not Loading Rows, Requested unkown parameter 'EID' for row 0.

jaredgerberjaredgerber Posts: 40Questions: 10Answers: 0
edited January 2015 in Free community support

This is the error I'm getting: Datatables warning: table id=commissionsschedule - Requested unkown parameter 'EID' for row 0.

I see the correct number of rows loading to the table, but the data is not loading. I'm using the latest datatables trial download, Editor & tableTools (DataTables-1.10.4-trial).

Here is the link:
http://174.120.222.66/~opes/admin/rpt_commission_scheduleZ.php#cas

Here is my document ready function:

$(document).ready(function() {
    editor = new $.fn.dataTable.Editor( {
        ajax: "php/processList.php?list=commissionschedule&has_form=false",
        table: "#commissionschedule",
        fields: [ {
                label: "PlanID:",
                name: "EID"
            }, {
                label: "Commission Type:",
                name: "CommissionTypeID"
            }, {
                label: "Commission%:",
                name: "CommPct"
            }, {
                label: "Target%:",
                name: "Target"
                }
        ]
    } );

Here is sample output from the processList.php:

{"sEcho":0,"iTotalRecords":"218","iTotalDisplayRecords":"218","aaData":[
["2","1","1.15","0.55"],
["3","1","1.1","0.53"],
["66","1","1","0.51"],
["75","1","1.15","0.55"],
["1632","1","0.075","0.025"],

I'm also running the server script, but I'm getting a database connection error there too:

$db = NEW mysqli("localhost", "opes", "mypass", "opes_com_track");
include( "../res/DataTables/php/DataTables.php" );
Editor::inst( $db, 'tlkpcommissionschedule' )

Can anyone tell me what I am doing wrong?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    Answer ✓

    Hi,

    Your data is array based (e.g. ["1","2","1","1.15","0.55"]) but you are specifically telling DataTables to except object based data through the use of the columns.data option.

    You can use arrays for DataTables and Editor by setting columns.data and fields.data to be integer values, but if you can alter the server-side script to send back objects, it might be easier in the long run.

    It might also be worth reading the data section of the manual about this topic.

    Allan

  • jaredgerberjaredgerber Posts: 40Questions: 10Answers: 0

    Thank you for pointing me in the right direction. I've read the data section in the manual now :-) I'm looking forward to seeing this inline editor running.

    I removed the column & field specifications and it started working. As you recommended, I'm trying to get my scripts to return objects instead.

    I've encoded the data using the server side script in the "Object data source" example:
    https://datatables.net/examples/server_side/object_data.html

    But it's outputting arrays:
    http://174.120.222.66/~opes/admin/php/processListObj.php

    Do I need to use different parameters for the json_encode() call?
    ...
    echo json_encode(
    SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
    ...

  • jaredgerberjaredgerber Posts: 40Questions: 10Answers: 0

    SUCCESS!!

    Ok -- I got my php script to return objects -- yayyy!!
    http://174.120.222.66/~opes/admin/php/processListObj.php?list=commissionschedule&has_form=false

    Also, I got the inline editor up and running!!
    http://174.120.222.66/~opes/admin/rpt_commission_scheduleZ.php#cas

    Now for getting it to save back to the server & a little styling / column formatting.

    Thanks.

  • jaredgerberjaredgerber Posts: 40Questions: 10Answers: 0
    edited January 2015

    It's editing the data now, how can I get it to update the table from my edits?

    http://174.120.222.66/~opes/admin/rpt_commission_scheduleZ.php#cas

    The changes I make in the grid are not getting saved back to my table -- am I missing something here?

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin

    It's editing the data now, how can I get it to update the table from my edits?

    Does your "php/processListObj.php?list=commissionschedule&has_form=false", script implement Editor's client / server communication requirements?

    Allan

  • jaredgerberjaredgerber Posts: 40Questions: 10Answers: 0
    edited January 2015

    I don't think so -- I'll check that out.
    ```
    <?php
    require_once ("../../Library/dbCon.php");

    /*
    * DataTables example server-side processing script.
    * See http://datatables.net/usage/server-side for full details on the server-
    * side processing requirements of DataTables.
    * @license MIT - http://datatables.net/license_mit
    */

    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    * Easy set variables
    */

    // DB table to use
    $table = 'qrycommissionschedule';

    // Table's primary key
    $primaryKey = 'CommissionScheduleID';

    // Array of database columns which should be read and sent back to DataTables.
    // The db parameter represents the column name in the database, while the dt
    // parameter represents the DataTables column identifier. In this case simple
    // indexes
    $columns = array(
    array( 'db' => 'CommissionScheduleID', 'dt' => 'CommissionScheduleID' ),
    array( 'db' => 'DT_RowID', 'dt' => 'DT_RowId' ),
    array( 'db' => 'EID', 'dt' => 'EID' ),
    array( 'db' => 'CommissionTypeID', 'dt' => 'CommissionTypeID' ),
    array( 'db' => 'CommPct', 'dt' => 'CommPct' ),
    array( 'db' => 'Target', 'dt' => 'Target' )
    );

    // SQL server connection information
    $sql_details = array(
    'user' => $GLO_USER_NAME,
    'pass' => $GLO_PASS,
    'db' => $GLO_DB_NAME,
    'host' => $GLO_HOST_NAME
    );

    require( '/home/opes/public_html/res/DataTables/php/ssp.class.php' );

    echo json_encode(
    SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
    );

    <?php > ``` ?>
  • jaredgerberjaredgerber Posts: 40Questions: 10Answers: 0

    Thanks again for your response.

    I have reviewed http://editor.datatables.net/manual/server -- I couldn't find an example script that handles edit, create or remove. I saw the sample data exchanges - is there a sample server side script for handling those data exchanges?

    Thank you.

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    edited January 2015

    is there a sample server side script for handling those data exchanges?

    Certainly - in the Editor download package. See installation instructions.

    Note that the Editor PHP libraries support server-side processing themselves. You don't need to use the ssp.class.php file.

    Edit Example of Editor with server-side processing using the Editor libraries: http://editor.datatables.net/examples/simple/server-side-processing.html .

    Allan

  • jaredgerberjaredgerber Posts: 40Questions: 10Answers: 0
    edited January 2015

    Ok on ssp -- thanks.

    So -- I don't have to code the handlers manually for edit, create & remove? I thought that there should be a simple way to get data back to the tables. I just can't put the puzzle together :-)

    In your examples, I see that it's actually saving data -- which is what makes me thing there is 2 way exchanges going on. However, I don't see any onsubmit=function() calls in your samples. So I'm a bit confused about how things get done.

    Does this sample that you're referring to here process post data to the table or is it posting to the datatables?
    http://editor.datatables.net/examples/simple/server-side-processing.html

        ->process( $_POST )
        ->json();
    
  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin

    onsubmit=function()

    There isn't - it is all handled by Editor. When you click the submit button in the Editor form it calls submit() which submits the data to the server.

    Does this sample that you're referring to here process post data to the table or is it posting to the datatables?

    It is processing the data contained in the $_POST variable.

    Allan

This discussion has been closed.