stwe / DatatablesBundle

This Bundle integrates the jQuery DataTables plugin into your Symfony application.
355 stars 236 forks source link

Extensions should be more dynamic #819

Open stephanvierkant opened 6 years ago

stephanvierkant commented 6 years ago

I'd like to use the FixedColumns extension, but that requires changing \Sg\DatatablesBundle\Datatable\Extensions and Resources/views/datatable/extensions.html.twig.

I can create a PR to add this feature, but I feel like this shouldn't be needed. I love OOP, but this seems over engineered. Configuring the OptionsResolver and using Twig to generate JSON is quite overkill, isn't it?

As an example, see 87d122ce0f6c9a1d8541dbe189e6df7e9a8eb1ee. It's a very complex, inflexible and over-engineered way of printing a JSON string.

Replacing \Sg\DatatablesBundle\Datatable\Extensions by an array makes more sense. Datatables.net's JS library should be use to handle configuration errors in this case.

What do you think?

philippemilink commented 6 years ago

I completely agree.

Moreover, this could improve the performance by avoiding including a lot of Twig templates.

stephanvierkant commented 6 years ago

Ping @stwe @Seb33300

Please let me know how you think about this idea. I'm willing to create a PR, but I'd like to know if this PR makes a chance in the first place.