Switching between tables for data
Switching between tables for data
Hi,
I've built out my app that dynamically loads CSV datasets and redraws the table based on dropdown, works great. Now I want to convert it to use the editor and database so I can have multiple users go in and edit/save different datasets.
If I have 10 sets of data, do I need to create 10 tables and then call the API to switch between them (with them all sharing the same schema)? I was confused because it seems like the editor just works with one table to do all the editing. Trying to understand it from an architecture point of view.
Thanks!
This question has an accepted answers - jump to answer
Answers
Essentially yes, that is what you would need to do. Are the data sets completely different from each other (e.g. a file of "passengers", one of "cars", one of "parts", etc). Or are they all basically the same but contain different data?
Allan
Hey Allan,
They're all the same, essentially we're exporting a list of every department's documents to be reviewed for migration, and then give them the opportunity for users to select their department and add predefined meta deta. In this case all the headers would be identical with just the data changing when you select marketing vs accounting.
If I'm going to be generating a lot of rendered columns, should I stick with client side vs server side processing as I'll need to send that data back to the database. And in that case, would it be best to use the API to handle that updating to the DB?
If they are all the same I'd be tempted to reuse the same table.
clear()
to clear out the old data and thenrows.add()
to add the new ones from wherever they are (ajax?).Server-side processing is a performance decision for the amount of data. Typically I would say for a table with 5-10 columns and >50'000 rows, then use server-side processing. DataTables doesn't attempt to do any kind of virtual rendering for columns, so there isn't a huge amount of performance gain by switching to server-side processing earlier. It really depends on the amount of data and the time take to transmit, read and render that.
Regards,
Allan
I'll probably stick with client side then. I was planning on redrawing the same table using those functions, this was my old code using CSV I think I can resuse;
So in this case, would I just want to create the 10 tables with the same structure, and then when it's passed into the existing datatable, the datatable is smart enough to understand which table was loaded and apply the edits/saves to that table?
Should I continue to initialize the data in the datatables config using "data: xxx" or is there a better way with data pulled from MySQL?
Thanks for all your help!
No - you'd need to trigger any saved via the API methods or Ajax calls depending on exactly where you want to save the data.
You can either use
data
or have DataTables load the data for you via Ajax withajax
(the latter has the benefit of then allowing the use ofajax.reload()
to be used). The fact that it is a MySQL database is actually irrelevant to DataTables itself.Allan