In my application I have a few grids that each get their data source from an ApiController action. I want to add an option for the user to export these grid into either CSV, PDF, Excel, etc. Writing code to convert the datasource to the expected format is not problem. The problem is that I want to write re-usable code. Currently I have a separate action for each grid.
I could very easily add a new Export controller with matching actions that call into the same logic as the ApiController, but that means if I have five ApiController actions I will need five additional Controller actions.
What i'm wondering if if there was a way I could make a single export Controller action, but somehow pass the details for the ApiController to it.
Any suggestions?