http://datatables.net/tn/4

http://datatables.net/tn/4

yvesmexyvesmex Posts: 7Questions: 2Answers: 0

Hello,
I am trying to set up a table using your example "Always Shown Chexbox". I have copied the scripts and adapted it to match mysql table. When I run my script I get this error: DataTables warning: table id=example - Requested unknown parameter 'operador' for row 0, column 0. I went through the explanation in tn/4 but frankly I don't get it.
Maybe you could have a look: arquigprs1.com/ss_casetas.php
the mysql table has these columns: id,autopista,operador,caseta,iave,ubiKm,lat,lon,link,tramo,distance,active but I only use these: operador,caseta,iave,ubiKm,link,active. Aall the cells are text and have data in it.
Many thanks for your help
Yves

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,448Questions: 26Answers: 4,974
    Answer ✓

    Your JSON data looks like this:

    {
        "data": [{
            "DT_RowId": "row_1",
            "first_name": "Quynn",
            "last_name": "Contreras",
            "phone": "1-971-977-4681",
            "city": "Slidell",
            "zip": "81080",
            "active": "0"
        }, {
    

    But in Datatables you defined the columns like this:

          columns: [
             { data: "operador" },
             { data: "caseta" },
             { data: "ubiKm" },
             { data: "iave" },
             { data: "link" },
             { data: "active",
                render: function ( data, type, row ) {
                   if ( type === 'display' ) {
                        return '<input type="checkbox" class="editor-active">';
                   }
                return data;
                },
                className: "dt-body-center"
             }
          ],
    

    The only name that matches is "active". The error is stating it can't find an object called "operador". Instead of object names like "first_name", "last_name", etc you need to return objects with the names that match your Datatables config like "operador", "caseta", etc.

    Kevin

  • yvesmexyvesmex Posts: 7Questions: 2Answers: 0

    Hello Kevin,
    Thanks for your analisis.
    The problem is that I did'nt do any JSON script
    I only use the HTML script + the php script that's all.
    Where does the JSON part comes from?

  • yvesmexyvesmex Posts: 7Questions: 2Answers: 0

    I got it. I have to modify the checkbox.php script also.
    Thanks for showing me the way.
    Yves

This discussion has been closed.