server state save/load problem

server state save/load problem

gorangoran Posts: 2Questions: 0Answers: 0
edited October 2012 in General
first of all let me say that this is a GREAT component :)

Now the problem, i have a little load/save state problem.;
this is my datatable initialisation :

[code]
$(document).ready( function() {
$('#example').dataTable( {

"bProcessing": true,
"sAjaxSource": 'table/get-data'

// ome of my other properties


"bStateSave": true,
"fnStateSave": function (oSettings, oData) {
$.ajax( {
"url": "/table/state-save",
"data": oData,
"dataType": "json",
"method": "POST"
"success": function () {}
} );

"fnStateSave": function (oSettings, oData) {
$.ajax( {
"url": "/table/state-load",
"data": oData,
"dataType": "json",
"method": "POST"
"success": function (json) { o = json; }
} );

}
} );
} );
[/code]

in the save procedure i get :

[code]

ColReorder[] 0
ColReorder[] 1
ColReorder[] 2
ColReorder[] 3
ColReorder[] 4
ColReorder[] 5
ColReorder[] 6
ColReorder[] 7
ColReorder[] 8
ColReorder[] 9
ColReorder[] 10
aaSorting[0][] 0
aaSorting[0][] asc
aaSorting[0][] 0
abVisCols[] true
abVisCols[] true
abVisCols[] true
abVisCols[] true
abVisCols[] true
abVisCols[] true
abVisCols[] true
abVisCols[] true
abVisCols[] true
abVisCols[] true
abVisCols[] true
aoSearchCols[0][bCaseInse... true
aoSearchCols[0][bRegex] false
aoSearchCols[0][bSmart] true
aoSearchCols[0][sSearch]
aoSearchCols[10][bCaseIns... true
aoSearchCols[10][bRegex] false
aoSearchCols[10][bSmart] true
aoSearchCols[10][sSearch]
aoSearchCols[1][bCaseInse... true
aoSearchCols[1][bRegex] false
aoSearchCols[1][bSmart] true
aoSearchCols[1][sSearch]
aoSearchCols[2][bCaseInse... true
aoSearchCols[2][bRegex] false
aoSearchCols[2][bSmart] true
aoSearchCols[2][sSearch]
aoSearchCols[3][bCaseInse... true
aoSearchCols[3][bRegex] false
aoSearchCols[3][bSmart] true
aoSearchCols[3][sSearch]
aoSearchCols[4][bCaseInse... true
aoSearchCols[4][bRegex] false
aoSearchCols[4][bSmart] true
aoSearchCols[4][sSearch]
aoSearchCols[5][bCaseInse... true
aoSearchCols[5][bRegex] false
aoSearchCols[5][bSmart] true
aoSearchCols[5][sSearch]
aoSearchCols[6][bCaseInse... true
aoSearchCols[6][bRegex] false
aoSearchCols[6][bSmart] true
aoSearchCols[6][sSearch]
aoSearchCols[7][bCaseInse... true
aoSearchCols[7][bRegex] false
aoSearchCols[7][bSmart] true
aoSearchCols[7][sSearch]
aoSearchCols[8][bCaseInse... true
aoSearchCols[8][bRegex] false
aoSearchCols[8][bSmart] true
aoSearchCols[8][sSearch]
aoSearchCols[9][bCaseInse... true
aoSearchCols[9][bRegex] false
aoSearchCols[9][bSmart] true
aoSearchCols[9][sSearch]
iCreate 1349186947583
iEnd 0
iLength 10
iStart 0
oSearch[bCaseInsensitive] true
oSearch[bRegex] false
oSearch[bSmart] true
oSearch[sSearch]

[/code]

I'm not sure what form is this or what do i have to return back :)

i try to return :

[code]{"aaSorting":[1,"des"]}[/code]

and got : TypeError: c.abVisCols is undefined

then I extended my json :

[code]{"aaSorting":[1,"des"],"abVisCols":[true,true,true,true,true,true,true,true,true,true,true]}[/code]

and i got : TypeError: k is undefined

im not sure where to go from here :)
what am i doing wrong :)

is there a list of mandatory fields i need to send?

p.s. i i'm using java spring mvc

Replies

  • gorangoran Posts: 2Questions: 0Answers: 0
    solved.

    i have set fnStateSave to return json :

    [code]
    "fnStateSave": function (oSettings, oData) {
    $.ajax( {
    "url": "/table/state-save",
    "data": 'jsonData=' + JSON.stringify(oData)",
    "dataType": "json",
    "method": "POST"
    "success": function () {}
    } );
    [/code]
  • allanallan Posts: 63,395Questions: 1Answers: 10,451 Site admin
    I think you'll need to set async: false on the fnStateLoad since there is no callback provided by DataTables. Otherwise the loaded state will occur after DataTables has attempted to apply the saved state.

    Allan
This discussion has been closed.