Skip to content

Instantly share code, notes, and snippets.

@donovan-duplessis
Last active December 26, 2015 12:48
Show Gist options
  • Save donovan-duplessis/7153420 to your computer and use it in GitHub Desktop.
Save donovan-duplessis/7153420 to your computer and use it in GitHub Desktop.
datatables instantiation options:
save/load in localstorage
bStateSave: true
fnStateSave: (oSettings, oData) ->
localStorage.setItem window.location.hostname.replace(/\./g, '_') + "_DataTables_" + window.location.pathname, JSON.stringify(oData)
fnStateLoad: (oSettings) ->
JSON.parse localStorage.getItem(window.location.hostname.replace(/\./g, '_') + "_DataTables_" + window.location.pathname)
iCookieDuration: 60*60*24, # 1 day (in seconds)
re-populate individual column filters:
fnInitComplete: (oSettings, json) ->
cols = oSettings.aoPreSearchCols
i = 0
while i < cols.length
value = cols[i].sSearch
$("thead input")[i].value = value if value.length > 0
i++
localstorage keys:
0_0_0_0_DataTables_/admin/divisions:{"iCreate":1382700973490,"iStart":0,"iEnd":0,"iLength":25,"aaSorting":[[0,"asc",0]]...}
0_0_0_0_DataTables_/admin/home:{"iCreate":1382700839163,"iStart":0,"iEnd":0,"iLength":25,"aaSorting":[[0,"asc",0]],...}
0_0_0_0_DataTables_/admin/products:{"iCreate":1382701318218,"iStart":0,"iEnd":0,"iLength":25,"aaSorting":[[0,"asc",0]]...}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment