omines / datatables-bundle

DataTables bundle for Symfony
https://omines.github.io/datatables-bundle/
MIT License
251 stars 113 forks source link

How can I show a total row? #227

Closed lookitsjonno closed 2 years ago

lookitsjonno commented 3 years ago

I would like to add a footer row showing the sum of some columns (for all pages)

Thanks

maxhelias commented 3 years ago

You can modify the default options to load into DataTables like that (this is my config with bootstrap 4) :

# config/packages/datatables.yaml
datatables:
    options:
        dom: "<'row' <'col-md-6' B><'col-md-6 ml-md-auto' f>><'row' <'col-md-12 overflow-auto' tr>><'row' <'col-md-6'i><'col-md-6 text-right'p>>"

All option is documented here : https://datatables.net/reference/option/dom

jkabat commented 3 years ago

I'm not sure @maxhelias comment answers your question, but you can still use native datatables features. In this case footerCallback.

https://datatables.net/examples/advanced_init/footer_callback.html

maxhelias commented 3 years ago

Oups I misunderstood 😅 Thanks