Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dynamic defaults #250

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

manusfreedom
Copy link

Useful for retrieving default values from Ajax or for defining certain parameters using a function) :

$.fn.dataTable.defaults = function(){
    myDefault = $.extend({}, $.fn.dataTable.defaults, { "serverSide": true });
    myDefault.stateSave = getFromAjax($(this).attr("id"), "stateSave");
    return myDefault;
}

Useful for retrieving default values from Ajax or for defining certain parameters using a function) :
```js
$.fn.dataTable.defaults = function(){
    myDefault = $.extend({}, $.fn.dataTable.defaults, { "serverSide": true });
    myDefault.stateSave = getFromAjax($(this).attr("id"), "stateSave");
    return myDefault;
}
```
@AllanJard
Copy link
Contributor

Thanks for suggesting this. I'm not sure about it to be honest, but then that might just be because I'm not to sure where this would be useful over just setting the defaults in a common function. Are you able to give an example?

Thanks!

@manusfreedom
Copy link
Author

manusfreedom commented Nov 17, 2023

We mainly use Datatables for 50 different tables and store personal parameters in our database using an API, but each table has its own specific parameters (and some can be global and overloaded) such as stateSave. Each table has its own JS, so there's no need to put common managed (but personal) parameters on each JS.
We give users the choice of using a default saveState value, but this can be overridden in each table and linked to the user rather than the session/browser.

Edit: We use stateRestore extension too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants