jQWidgets Forums

jQuery UI Widgets Forums Grid how to use 2dimensional json in jqxgrid

This topic contains 2 replies, has 2 voices, and was last updated by  homam 12 years, 1 month ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • how to use 2dimensional json in jqxgrid #15951

    homam
    Member

    hi

    i have a 2 dimensional json as follows and i tried all possibilities i thought may work but i could not determin it can you help?

    here is my json (although it is really big here is just 2 of it) and i want only the contents of the result for my columns

    [
        {
            "status": 200,
            "result": [
                {
                    "filename": "00000129",
                    "fileid": 129,
                    "title": "aghati",
                    "duration": "",
                    "type": "RAW",
                    "ability": "PAUSE"
                },
                {
                    "filename": "00000130",
                    "fileid": 130,
                    "title": "moazenzade",
                    "duration": "",
                    "type": "RAW",
                    "ability": "PAUSE"
                }
            ]
        }
    ]
    how to use 2dimensional json in jqxgrid #15954

    Dimitar
    Participant

    Hello homam,

    Here is what to do:

                var json = '[{ "status": 200, "result": [{ "filename": "00000129", "fileid": 129, "title": "aghati", "duration": "", "type": "RAW", "ability": "PAUSE" }, { "filename": "00000130", "fileid": 130, "title": "moazenzade", "duration": "", "type": "RAW", "ability": "PAUSE"}]}]';
    var obj = $.parseJSON(json);
    var status = obj[0].status;
    var result = obj[0].result;
    // prepare the data
    var source =
    {
    datatype: "json",
    datafields: [
    { name: 'filename', type: 'string' },
    { name: 'field', type: 'int' },
    { name: 'title', type: 'string' },
    { name: 'duration' },
    { name: 'type', type: 'string' },
    { name: 'ability', type: 'string' }
    ],
    id: 'field',
    localdata: result
    };
    var dataAdapter = new $.jqx.dataAdapter(source);

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    how to use 2dimensional json in jqxgrid #15956

    homam
    Member

    HI
    best of the best thanks

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.