-
-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add server side export #83
Conversation
To support PHP 7.0
To maintain BC, it is not possible to type hint with the TranslatorInterface as older versions of Symfony inject "Symfony\Component\Translation\TranslatorInterface" while newer versions of Symfony inject "Symfony\Contracts\Translation\TranslatorInterface".
The 'render' column option is usually use to inject HTML.
Tests were passing using "Symfony\Component\Translation\DataCollectorTranslator" as type-hint but Symfony may inject "Symfony\Bundle\FrameworkBundle\Translation\Translator".
* Using a Generator makes the code more readable. * Avoid creating an array (iterator_to_array) may be sligtly faster?
@shades684 changes make sense afaics, your opinion? |
Hi @curry684, thank you for reviewing my pull request. I think some things should be improved. For example, it would be better to automatically tag classes that implement I need to add more tests. I'm using my fork in production and a However, exported data can be confusing depending of the |
https://github.com/omines/datatables-bundle/blob/94777da/src/Column/AbstractColumn.php#L68-L77 |
…-export # Conflicts: # composer.json # src/DataTable.php # src/DataTableFactory.php # tests/Fixtures/services.yml
Export the entire table but keep current sort and filtering
Hi @curry684 , I've been using my Could you also test it on one of your project? As soon as you tell me everything is fine and my implementation is correct, I will add :
Then, I believe this PR will be ready to be merged! |
Will not fix #122 but should prevent similar issues.
* Symfony 3 is not supported, according to the readme.md Symfony 3 is not supported, according to the readme.md. This updates the documentation to reflect that only Symfony 4.1+ is supported by this bundle * Update index.html.md
Alternative to #125
This is actually obsolete since Symfony Flex, as you can now run Symfony 4.1 with more recent components.
To support PHP 7.0
To maintain BC, it is not possible to type hint with the TranslatorInterface as older versions of Symfony inject "Symfony\Component\Translation\TranslatorInterface" while newer versions of Symfony inject "Symfony\Contracts\Translation\TranslatorInterface".
The 'render' column option is usually use to inject HTML.
Tests were passing using "Symfony\Component\Translation\DataCollectorTranslator" as type-hint but Symfony may inject "Symfony\Bundle\FrameworkBundle\Translation\Translator".
* Using a Generator makes the code more readable. * Avoid creating an array (iterator_to_array) may be sligtly faster?
Export the entire table but keep current sort and filtering
…atatables-bundle into server-side-export
Wow, maybe I should have |
I have no good way to test at the moment and the PR is unreviewable due to the rebase, so I'll just merge it and we'll see how the community likes it :P |
Thanks @curry684! I'm watching this repository so I'll be responsive if someone opens an issue about this feature. 😉 |
It would seem something in Symfony 5 broke it: https://travis-ci.org/github/omines/datatables-bundle/jobs/703172222
Also a fatal:
Not really sure what's behind this. Could you have a look? I'm holding off |
This Bundle only allows server side processing. This raises an issue when it comes to use the HTML5 export buttons. These buttons only export the current page (as the DOM is only aware of the current page).
This pull request aims to fix this limitation.
Usage
I suggest you look at the
ExporterController
and theexporter.html.twig
file for a complete usage example.How it works
Front-end
https://github.com/MaximePinot/datatables-bundle/blob/10e586c98cb3c4f2f167828a932ef9180551e33d/tests/Fixtures/AppBundle/Resources/views/exporter.html.twig#L11-L26
Adding an export button must be handled by the front-end developer as it is not the Bundle's concern to manage/render anything. As the Bundle still needs some specific parameters to be sent, I created a function that generates the function needed by the
action
option.Back-end
Everything is handled automatically by the Bundle and its current structure (
isCallback
/getResponse
) is not changed (see this piece of code).To trigger an "export state", the request must be sent with a
_exporter
parameter (along with the usual_dt
parameter) whose value is the name of the DataTable exporter (defined by thegetName()
method).At the moment, I only created an
Excel
exporter. I think the Bundle should be shipped with a few common exporters such asPDF
,CSV
andHTML
. I plan to add these three, but I want to be sure that my implementation is correct before.Anyone can add a DataTable exporter to its project by creating a service class that implements the
Omines\DataTablesBundle\Exporter\DataTableExporterInterface
. The service must be tagged withdatatables.exporter
.Documentation
I did not write any documentation yet. I first want to be sure that my implementation is correct. When this pull request is ready to be merged. I will add a commit that adds a
Server side export
section to the documentation.