DataTables Bundle for Symfony2
DataTables Bundle for Symfony2
brown298
Posts: 3Questions: 0Answers: 0
Hi,
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:
Packagist: https://packagist.org/packages/brown298/data-tables-bundle
Source: https://bitbucket.org/brown298/datatablesbundle.git
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.
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:
Packagist: https://packagist.org/packages/brown298/data-tables-bundle
Source: https://bitbucket.org/brown298/datatablesbundle.git
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.
This discussion has been closed.
Replies
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!).
Regards,
Allan
One of the features I would like to see is easy row grouping: http://datatables.net/examples/advanced_init/row_grouping.html
Here's a snippet:
[code]
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);
}
[/code]
I will try your bundle and if it works fine I will do some pull requests as well ;-)
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:
[code]
function ( oSettings ) {
if ( oSettings.aiDisplay.length == 0 ) {
return;
}
var nTrs = $('tbody tr', oSettings.nTable);
var iColspan = nTrs[0].getElementsByTagName('td').length;
var sLastGroup = "";
for ( var i=0 ; i
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?
Thanks.
"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": "http://www.datatables.net/releases/DataTables-1.9.4$
}
}
}
]
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.
And thanks for the support
I'am a newbie in Symfony2 and I would like to use the DataTables Bundle from "https://packagist.org/packages/brown298/data-tables-bundle"
I installed the bundle and do the required configuration from here "http://code.rbsolutions.us/datatables/ " 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 "http://code.rbsolutions.us/datatables/style/model/" 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.