Use datatables for "big" proyect admin backend

Use datatables for "big" proyect admin backend

ChemonChemon Posts: 19Questions: 0Answers: 0
edited December 2012 in General
Hi guys, i am spanish, sorry if my english isnt good.

Well, i am developing an online shop web application with PHP. I am right now with the backend, the private side where u can administrate the shop.

I started study datatables 1 week ago or something like that. It looks great.

I have something in mind, develop a big part of administration modules with datatables. This is inserts, edits, deletes, pagination, filters, ordering, hide/show ... for all "modules" ( shop sections, products, invoices, clients, users, roles, ...)

So i want to know if this can be made with datatables not hard way, i mean, dont having to be very pro with datatables because i am relatively new.

I am going to use server-side proccessing.
My targets are build an aplication where admin can administrate roles ( create, edit, .., access to data ).
Access to data means for example,
that a specific user only can see some diferents columns data from a specific module.
or that a specific user can see some columns on the interface but not be able to edit them.

I know how to store and take the role/user/resources info on data base ( DB ).

What I want to know if it is possible create a server-side php code to create a Json with all the info needed to load data on datatables depending from user privileges; the order,pagination,filters he choosed; ... and i want to know if isnt hard.

I hope have explained well.

I have doubts about what minimum html code i must create.
[code]















[/code]
how do i create Json to send column tittles.
I am trying with
[code]
...
array_push($datosSalida["aaData"], array("Tasman", "Internet Explorer 4.5", "Mac OS 8-9", "-", "X"));
$datosSalida["aoColumns"] = array ();
array_push( $datosSalida["aoColumns"], array(
array( "sTitle" => "Engine" ),
array( "sTitle" => "Browser" ),
array( "sTitle" => "Platform" ),
array( "sTitle" => "Version" ),
array( "sTitle" => "Grade" ))
);
array_push( $datosSalida["aoColumns"], array(
array( "mData" => "engine" ),
array( "mData" => "browser" ),
array( "mData" => "platform" ),
array( "mData" => "version" ),
array( "mData" => "grade" ))
);
echo json_encode( $datosSalida );
[/code]

Replies

  • allanallan Posts: 63,252Questions: 1Answers: 10,420 Site admin
    > What I want to know if it is possible create a server-side php code to create a Json with all the info needed to load data on datatables depending from user privileges; the order,pagination,filters he choosed; ... and i want to know if isnt hard.

    Yes this is absolutely possible and I've done it several times myself - however, how it is implemented and how complex it is is entirely up to you and how you design and create your system! :-).

    You could have some seriously complex software if you needed / wanted, or you could add a little bit of logic to my basic demo script.

    Allan
  • ChemonChemon Posts: 19Questions: 0Answers: 0
    edited December 2012
    Ty for answering so fast,

    Well, I would like to know what datatable parameters are sent to the server on a Post server processing sent.

    only these ?
    [code]
    bRegex false
    bRegex_0 false
    bRegex_1 false
    bRegex_2 false
    bRegex_3 false
    bRegex_4 false
    bSearchable_0 true
    bSearchable_1 true
    bSearchable_2 true
    bSearchable_3 true
    bSearchable_4 true
    bSortable_0 true
    bSortable_1 true
    bSortable_2 true
    bSortable_3 true
    bSortable_4 true
    iColumns 5
    iDisplayLength 10
    iDisplayStart 0
    iSortCol_0 3
    iSortingCols 1
    mDataProp_0 0
    mDataProp_1 1
    mDataProp_2 2
    mDataProp_3 3
    mDataProp_4 4
    sColumns
    sEcho 3
    sSearch
    sSearch_0
    sSearch_1
    sSearch_2
    sSearch_3
    sSearch_4
    sSortDir_0 asc
    [/code]

    I know i can sent all that i want
    [code]
    oTable = $('#example').dataTable({
    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": "http://gestionmimascota.loc/categorias/cargaDatos",
    "sServerMethod": "POST",
    /*"fnServerParams": function ( aoData ) {
    aoData.push( { "name": "more_data", "value": "my_value" } );
    }*/
    ...
    [/code]

    I dont have column's titles on html.
    I send column's sTitles on the Json but it doesnt draw on table.
    Do i must write some javascript callback function to it be printed with each Ajax callback ?

    :(
This discussion has been closed.