stateLoadCallback json format

stateLoadCallback json format

alexvremjaalexvremja Posts: 11Questions: 2Answers: 1

Hi!
since have multiple table and multiple users and need to save State for all of them I'm willing to save everything in a database table.
I formatted the State as follows (after deleting some info):
columns[0][visible]="true"|columns[1][visible]="true"|columns[2][visible]="true"|columns[3][visible]="true"|columns[4][visible]="true"|ColReorder[]="0, 1, 4, 3, 2"|length="216"|time="1444666842670"|start="0"|iScroller="0"|iScrollerTopRow="0"|order[0][]="0, asc"

but now I have to load State with stateLoadCallback, I understand I have to rebuild a json response but do not know exactly how to do it:
Can someone provide an example of how should be formatted such json file?

thanks

Alex

Answers

  • alexvremjaalexvremja Posts: 11Questions: 2Answers: 1

    Got it..
    just some tests..
    If can be interesting for somebody.. this is the format:

        {
            "colReorder": [
                0,
                1,
                4,
                3,
                2
            ],
            "columns": [
                {
                    "visible": true
                },
                {
                    "visible": true
                },
                {
                    "visible": true
                },
                {
                    "visible": true
                },
                {
                    "visible": true
                }
            ],
            "iScroller": 0,
            "iScrollerTopRow": 0,
            "start": 0,
            "length": 216,
            "time": 1444673072855
        }
    
  • ty105ty105 Posts: 15Questions: 5Answers: 0

    object would be like this right? does mine look right?

    {
                                "colReorder": [
                                    0,
                                    1,
                                    2,
                                    3,
                                    4,
                                    5,
                                    6,
                                    7,
                                    8,
                                    9,
                                    10,
                                    11,
                                    12,
                                    13,
                                    14,
                                    15,
                                    16                              
                                ],
                                "colResize:": {
                                    "columns": [
                                        "48px",
                                        "95px",
                                        "",
                                        "144px",
                                        "180px",
                                        "120px",
                                        "101px",
                                        "109px",
                                        "118px",
                                        "83px",
                                        "69px",
                                        "73px",
                                        "117px",
                                        "112px",
                                        "128px",
                                        ""
                                    ],
                                    "tableSize": 1667
                                },
                                "columns": [
                                    {
                                        "visible": true
                                    },
                                    {
                                        "visible": true
                                    },
                                    {
                                        "visible": true
                                    },
                                    {
                                        "visible": false
                                    },
                                    {
                                        "visible": true
                                    },
                                    {
                                        "visible": false
                                    },
                                    {
                                        "visible": false
                                    },
                                    {
                                        "visible": false
                                    },
                                    {
                                        "visible": false
                                    },
                                    {
                                        "visible": false
                                    },
                                    {
                                        "visible": false
                                    },
                                    {
                                        "visible": false
                                    },
                                    {
                                        "visible": false
                                    },
                                    {
                                        "visible": false
                                    },
                                    {
                                        "visible": false
                                    },
                                    {
                                        "visible": false
                                    },
                                    {
                                        "visible": true
                                    }
                                ],
                                "length": -1,
                                "start": 0,
                                "time": 1447101052821
                            };
    
  • alexvremjaalexvremja Posts: 11Questions: 2Answers: 1

    no.. it is not a correct json answer:

    you can validate here:

    http://jsonlint.com/

    answer is
    Parse error on line 98:
    ...me": 1447101052821};
    ----------------------^
    Expecting 'EOF', '}', ',', ']'

    you have to avoid the ; at the end.

    for the rest seems OK

This discussion has been closed.