Adding checkbox column on server-side + field search

Adding checkbox column on server-side + field search

rmoni3000rmoni3000 Posts: 3Questions: 0Answers: 0
edited July 2011 in General
Hi guys, I started to work with datatables and mixed up server-side datatable with live field search... but, I am not figuring out how to add a column with checkbox... I have tryied a lot of things, searched all google and couldnt find anything to help, it returns the following message:

"DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error."

looks like, its missing one data column (which is the checkbox column), and then, he moves the table content to left, where should be that column...

if you guys could take a look, thats the adress:

http://aptasd.com.br/datatable/custom/


I'm really mad about this thing...

Replies

  • gmeridethgmerideth Posts: 7Questions: 0Answers: 0
    Could be that your php code returns

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM dados' at line 2

    and not json.
  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    Are the values of the checkboxes coming from the database?

    You can use fnRender for that column to create checkboxes, set the value depending on what is returned from the database.

    the example shows using a column def to run render on one column:
    http://www.datatables.net/release-datatables/examples/advanced_init/column_render.html
  • rmoni3000rmoni3000 Posts: 3Questions: 0Answers: 0
    I corrected gmerideth and thaaanks fbas, it worked, finally!

    I just had to add another properties and get again id on the first column as value for the checkbox :)



    [code]
    "aoColumnDefs": [
    {
    "fnRender": function ( oObj ) {
    return ' ';
    },
    "aTargets": [ 0 ]
    }
    ]
    [/code]


    server_side array, got 2 times the ID

    [code]
    $aColumns = array('id','id', 'nome', 'email', 'descricao', 'telefone');
    [/code]
  • numberonenumberone Posts: 86Questions: 0Answers: 0
    hi
    it seems multi filtering doesnt work.

    Use this :
    [code]
    $("tfoot th").keyup( function () {
    /* Filter on the column (the index) of this element */
    oTable.fnFilter( $(this).children("input").val(), $("tfoot th").index(this) );
    } );
    [/code]

    instead of :
    [code]
    $(".search input").keyup( function (){
    /* Filter on the column (the index) of this element */
    oTable.fnFilter( this.value, $(".search input").index(this) );
    });
    [/code]

    Regards,
    Yusuf
  • rmoni3000rmoni3000 Posts: 3Questions: 0Answers: 0
    hi yusuf, I already solved the problem, it wasn't the search function, its was beacuse I didnt had a search input for checkbox, neither for actions.

    now, everything is working fine.
  • ganapathy_paulrajganapathy_paulraj Posts: 16Questions: 0Answers: 0
    [code]
    ' ';
    [/code]

    found this was an issue am not able to get the data,,everything that i get on the 1st and 3rd positions is undefined

    can some one help me !
This discussion has been closed.