Database Viewer and Exporter.zip
The attached demo extends the database viewer module with an export feature. Note that it exports the contents of the display table, but you should be able to change the model and export directly from the database query.
Since the original database viewer (Common/Templates/Modules/Database Viewer) cannot be changed itself (it's in the common library which means it cannot be edited), I created a copy of it in the demo app using the copy package feature (right click on the package you wish to copy -> select Copy -> right click on the package into which you want to copy -> select Paste Package).
The differences you note in trace json serialization are related to client vs. server-side trace implementation and have no effect on actual processing.
For best results, use the Firefox browser..