server-side

server-side

psopapsopa Posts: 5Questions: 0Answers: 0
edited February 2013 in General
Hi
i've searched in the forum for examples on using server side data do fill a table with jquery/php/mysql/ajax, and i found several different ways of doing it, as well as adding extra columns, i.e. an actions column to add edit/delete/view buttons for each row.
i have to confess that i'm finding this a little bit confusing... can anyone point me out a clear example of interacting with database? thanks...
one other question: anyone knows if themeforest themes pointed here are the only ones or the best ones to interact with datatables?
thanks a lot!

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    > one other question: anyone knows if themeforest themes pointed here are the only ones or the best ones to interact with data tables?

    I've links to all the themes that I know of that use DataTables. I can't vouch for their quality.

    > i've searched in the forum for examples on using server side data do fill a table with jquery/php/mysql/ajax

    http://datatables.net/release-datatables/examples/data_sources/ajax.html

    Just have your server respond with JSON data and then use the DataTables options to read the data. The default is to read arrays of arrays, but you can easily read arrays of objects: http://datatables.net/blog/Extended_data_source_options_with_DataTables

    Allan
  • psopapsopa Posts: 5Questions: 0Answers: 0
    thank you
    and what is the best/correct way of adding extra columns in the table, i.e. columns that doesn't come with the database like an actions columns to edit/delete, etc records?
    i found several posts about it in the forums, but they all are a bit different... what is the recommended way of doing it?
    thanks again
  • psopapsopa Posts: 5Questions: 0Answers: 0
    Hello again...
    i'm almost loosing it... :)
    so i have a php file that returns json valid info:
    [
    {"id_categoria":"3","descricao_categoria":"bebidas","nome_categoria":"Bebidas","id_cliente":"1","estado_categoria":"1"},{"id_categoria":"4","descricao_categoria":"","nome_categoria":"Sandes","id_cliente":"1","estado_categoria":"1"},
    {"id_categoria":"5","descricao_categoria":"alcoolicas","nome_categoria":"Alcoolicas","id_cliente":"1","estado_categoria":"1"}
    ]

    and my html file i have:


    $(document).ready(function() {
    var oTable = $('#teste').dataTable( {
    "bProcessing": true,
    "sAjaxSource": "teste.php",
    "aoColumns": [
    { "mData": "id_categoria" },
    { "mData": "descricao_categoria" },
    { "mData": "nome_categoria" },
    { "mData": "id_cliente" },
    { "mData": "estado_categoria" }
    ]
    } );
    } );



    the result is only a loading message... no errors.
    what am i missing?
    thanks
  • psopapsopa Posts: 5Questions: 0Answers: 0
    ok, i found the problem: had to add sAjaxDataProp: "" to initialization... thanks anyway!
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    > sAjaxDataProp: ''

    Yup that was it. Sorry I missed your earlier posts.

    Allan
  • psopapsopa Posts: 5Questions: 0Answers: 0
    ok. no prob :)
This discussion has been closed.