olifolkerd / tabulator

Interactive Tables and Data Grids for JavaScript
http://tabulator.info
MIT License
6.74k stars 817 forks source link

Is there a way to save/load the state of a Tabulator object other than PersistentLayout? #362

Closed rjcorne closed 7 years ago

rjcorne commented 7 years ago

I would like to be able to export the current state of a Tabulator object including all the columns' order, visibility, and width. I looked into the PersistentLayout functionality which basically does this, but I was wondering if there are any functions available for me to pull that information directly from the Tabulator object instead of storing in localStorage or a cookie? The end goal would be a way for someone to export a particular view, save it to a file/database, and share this with someone else for them to load the same view.

Ideally this export would also include any filters and sorting applied , but that would be a lower priority.

Thanks!

olifolkerd commented 7 years ago

You used to be able to do that easily in version 2.12, but it appears that is no longer quite so simple in 3.0.

I will have a look into it tomorrow and see if i can reinstate that old functionality, it should be too much effort.

Cheers

Oli

olifolkerd commented 7 years ago

Hey,

I have just committed some changes to the 3.1 branch that should meet your needs.

The getColumnLayout function will retrieve the column layouts as an object (which is safe to JSON encode if you want)

var columnLayouts = $("#example-table").tabulator("getColumnLayout");

The setColumnLayout will take the layout object and apply it to the table

$("#example-table").tabulator("setColumnLayout", columnLayouts);

You can use the getFilter and getSort to get the filters and sorters currently applied to the table.

There will be an official release of 3.1 by the end of this weekend.

Cheers

Oli

rjcorne commented 7 years ago

Awesome! Thanks, Oli!

On Jun 17, 2017 10:40 AM, "Oli Folkerd" notifications@github.com wrote:

Hey,

I have just committed some changes to the 3.1 branch that should meet your needs.

The getColumnLayout function will retrieve the column layouts as an object (which is safe to JSON encode if you want)

var columnLayouts = $("#example-table").tabulator("getColumnLayout");

The setColumnLayout will take the layout object and apply it to the table

$("#example-table").tabulator("setColumnLayout", columnLayouts);

You can use the getFilter and getSort to get the filters and sorters currently applied to the table.

There will be an official release of 3.1 by the end of this weekend.

Cheers

Oli

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/olifolkerd/tabulator/issues/362#issuecomment-309222413, or mute the thread https://github.com/notifications/unsubscribe-auth/ACo-Kod08-pHz_mmXwcj30i62aIxFI0Pks5sE_OHgaJpZM4N3W9o .