DataTables Bundle for Symfony2

DataTables Bundle for Symfony2

brown298brown298 Posts: 3Questions: 0Answers: 0
edited November 2013 in Announcements

I thought this might be a good place to make a generic announcement. I am creating a bundle for Symfony2 and Doctrine2 to act as the server side for DataTables. The idea is to configure a DataTables 'model' on the server side and provide it with either a QueryBuilder or an array of data. The rest, sorting, paging, filtering gets translated and added onto the QueryBuilder.

For anybody interested:

I am going to continue adding features as I find them useful, but let me know if you would like something or want to help.


  • allanallan Posts: 61,584Questions: 1Answers: 10,084 Site admin
    Very nice! Symfony is something that I've been wanting to get to grips with for some time, so this might be just the ticket for me personally to get my feet wet, and I'm sure others will find it useful as well.

    I've added your release to the DataTables news feed and moved your post to the announcements category.

    One other thing I would say, the work I've been doing on DataTables 1.10 recently has been to revamp how the server-side communication protocol for DataTables works - this change is 100% backwards compatible, so all scripts that use the 1.9- scheme will continue to work! However, I mention it as it might possibly make your own development a little bit easier... For example, arrays are used to send column information rather than `bSortable_{i}` like parameters. Also, like the rest of 1.10 it is camelCase. If you are interested, let me know and I'll provide some more details, but as I say, the old SSP method will continue to work and will do so for the rest of the 1.x series (which is into the foreseeable future!).

  • svierkantsvierkant Posts: 33Questions: 2Answers: 0
    Very nice! I will give it a try. Last year I made a simple class for Datatables, but I'm switching to Symfony2.

    One of the features I would like to see is easy row grouping:

    Here's a snippet:
    if (isset($this->GroupByColumn))
    $data['groupby'] = $this->GroupByColumn;

    $data['parameters']["aoColumnDefs"][] = array('bVisible' => false, 'aTargets' => array($this->GroupByColumn));
    $data['parameters']['aaSortingFixed'][] = array($this->GroupByColumn, $this->GroupByColumnSort);

    I will try your bundle and if it works fine I will do some pull requests as well ;-)
  • brown298brown298 Posts: 3Questions: 0Answers: 0
    That sounds like a great idea. It sounds like you have done some of this before.

    I am thinking out-loud but, this brings up some design considerations to work through. It looks like there are three pieces of data that are required to accomplish this: fnDrawCallback, aoColumnDefs, and aaSortingFixed. So, on the twig side we could add a parameter "groupByColumn" that takes an array (in case we want to allow more than one).

    For the paramters; in the twig extension we could then merge aoColumnDefs with any specifically provided data and do the same thing to aaSortingFixed.

    That just leaves fnDrawCallback. I want to figure out a way to combine the grouping functionality with any other custom functionality. ie. if I want it to group and I want to have additional functionality in fnDrawCallback, then I should be able to do both.

    So, based on their example:
    function ( oSettings ) {
    if ( oSettings.aiDisplay.length == 0 ) {

    var nTrs = $('tbody tr', oSettings.nTable);
    var iColspan = nTrs[0].getElementsByTagName('td').length;
    var sLastGroup = "";
    for ( var i=0 ; i
  • svierkantsvierkant Posts: 33Questions: 2Answers: 0
    edited November 2013
    For the record: I'm already using this Bundle for testing purposes and I'm flooding brown298 with questions and feature requests. :)
  • campscamps Posts: 2Questions: 0Answers: 0
    edited December 2013
    Hi, thank´s for share your bundle.
    I´ve a problem when i try to install:

    - brown298/data-tables-bundle dev-master requires datatables/datatables dev-master -> no matching package found.

    some help?
  • campscamps Posts: 2Questions: 0Answers: 0
    Ready! need this:
    "datatables/datatables": "dev-master", previously in your composer.json.

    If not foud, add this:

    "repositories": [
    "type": "package",
    "package": {
    "name": "datatables/datatables",
    "version": "1.9.4",
    "dist": {
    "type": "zip",
    "url": "$
  • djlakesdjlakes Posts: 7Questions: 0Answers: 0
    Have you considered extracting the server side/ajax portion of things from the Twig/rendering portions? I ask because the library seems well documented and thought out, but it doesn't work with my current setup.

    I'm currently running a setup with DataTables + RequireJS, so having Twig handle my JS is out of the question. I believe having the server side/ajax layer as a separate component would make this library that much more functional.

    That said, fine work! Excited to see where this goes in the future.
  • brown298brown298 Posts: 3Questions: 0Answers: 0
    I am certainly not against that, I would say that we could split them and allow for configurable front ends and have the default bundle use composer tie them together. Is this something you would be willing to help (at least define the interfaces if not more)? I dont use require js, but being able to use different engines is certainly appealing. Let me know and we can talk about accomplishing this.

    And thanks for the support
  • afkiafki Posts: 1Questions: 0Answers: 0

    I'am a newbie in Symfony2 and I would like to use the DataTables Bundle from ""
    I installed the bundle and do the required configuration from here " " then I created my own Bundle to use the DataTables Bundle (as 3rd part bundle) then I began to applicate the model example from here "" but only the head of table is displayed (I test the query it's ok) and there is no error I Dont know if my approach is true.

This discussion has been closed.