Datatable preferences save in datatbase ?
Datatable preferences save in datatbase ?
I saw your this post https://datatables.net/forums/discussion/18337/complete-example-for-server-side-colreorder-colvis-tabletools-column-filtering-and-state-save before that I was trying this one https://datatables.net/forums/discussion/3700/colvis-get-list-of-hidden-or-shown-columns, can you help me to solve similar one for me also , I need to save column visibility an column reordering state of columns in database by using ajax url, also I am using spring+jpa+ mvc , can you provide me a example that how to get these all states and save in database of table preference table. I have one table which has data and another one is preference table which has one column called prefrences in which I need to save all columns name which are visible or user settings . thanks in advance.
Answers
I'm not familiar with Spring myself, so I'm not able to provide such an example. I'm sure if you post a freelance job on ODesk or similar though, you'll find people who can perform this work for you.
Allan
ok, not for spring but can you tell me exactly how I can save datatable settings and visible columns in one column of database column which has name "preferences" and then every time I need to get data according to that preferences table column to display.
You would use the DataTables API (
search()
,order()
,page.info()
, etc) to find out what the current state of the table is. That can then be saved any way you want, and restored using the API.Allan
ok, thanks, do I need to write "serverside=true" for saving.?
No. You need to write the code that will save the information to the database. That is not something DataTables has built in.
Allan
ok, so I have two questions here
1. so you mean serverside=true is not mandatory if i want to save my data in database other code is the only thing that I required , the problem is when I am making serverside true it becomes so slow and gives me full page data but not only 20 entries and also makes individual search disable......
2...and other thing I would like to ask is Can we customize the colvis plugin so that all the values can be save ones but not one by one for columns .??
IMHO...
you have not to mix up serverSide with stateSave
serverSide it is used if you load the table via $.ajax, but setting serverSide: true is clearly not enough: you have to write the serverside code to extract the table (from dB I suppose) and format it according to json rules.
stateSave:true allows you to save the colVis and colReorder (and Filters).
Save.. Where?
you can choose: if use only stateSave: true it is saved somewhere in broswer memory and lasts for a couple of hours: if want permanent saving you need to use
stateSaveCallBack and stateLoadCallback functions
and again write serverside scripts both to save the data and to reload data.
Beside this the example you mentioned are around 2 years old, and thus... little obsolete:
still using old DataTable version (dataTable and not DataTable), moreover colVis is deprecated since is included in buttons in latest versions: is much easier to handle and works better
Can see something here:
https://datatables.net/forums/discussion/30715/server-side-datatables-not-working-with-classic-asp#latest