Search code examples
javascriptjqueryw2ui

Data there, but not visible in grid


My scenario:
I have a w2ui data grid, data is coming from remote server by calling Rest api.
I can see the response data in browser debugger but not in the grid.
Please help. My code and Firebug snapshot below.

Thank you very much for any hints.

     $(function () {
        $('#grid').w2grid({
            method: 'GET',
            crossDomain: true,
            url: 'https://im-dev....net/bp/development/DETDS/Claims' + sSomeIds + sSession,
            dataType: 'json',
            name: 'grid',
            recid: 'clmNumber',
            show: {
                selectColumn: true,
                toolbar: true,
                footer: true,
                toolbarSave: true
                //toolbarAdd: true
            },
            columns: [
                {field: 'busUnit', caption: 'busUnit', size: '150px'},
                {field: 'catCodeC', caption: 'catCodeC', size: '150px'},
                {field: 'clmStatus', caption: 'clmStatus', size: '150px'},
                {field: 'clmStatusDesc', caption: 'Status', size: '150px'},
                {field: 'ctryCd', caption: 'Country', size: '100px'},
                {field: 'ctryDesc', caption: 'ctryDesc', size: '100px'},
                {field: 'department', caption: 'department', size: '80px'},
                {field: 'empName', caption: 'Requester', size: '140px'},
                {field: 'empcnum', caption: 'empcnum', size: '80px'},
                {field: 'enddate', caption: 'enddate', size: '80px'},
                {field: 'flmrgScr', caption: 'flmrgScr', size: '80px'},
                {field: 'groupCode', caption: 'groupCode', size: '80px'},
                {field: 'histScr', caption: 'histScr', size: '80px'},
                {field: 'imt', caption: 'IMT', size: '80px'},
                {field: 'iot', caption: 'IOT', size: '80px'},
                {field: 'mgrcnum', caption: 'mgrcnum', size: '80px'},
                {field: 'mgrname', caption: 'FLM', size: '140px'},
                {field: 'submitdate', caption: 'submitdate', size: '80px'},
                {field: 'clmNumber', caption: 'clmNumber', size: '80px'},
                {field: 'tepeScr', caption: 'tepeScr', size: '80px'},
                {field: 'tranScr', caption: 'tranScr', size: '80px'}
            ],
            onSubmit: function (event) {
                w2alert('save');
            }               
        });           
    });

FireBug snapshot >>>here<<<.


Solution

  • What exactly does your url return?

    Did you read the documentation on the expected structure?

    http://w2ui.com/web/docs/grid/overview#data-structures

    {
        "status"  : "success",
        "total"   : 36,
        "records" : [
            { "recid": 1, "field-1": "value-1", ... "field-N": "value-N" },
            ...
            { "recid": N, "field-1": "value-1", ... "field-N": "value-N" }
        ]
    }
    

    My guess is, you either don't give each record a unique recid, or you're not setting success/total.

    Edit: on a second glance, it looks as if you're returning an array from the server, instead of wrapping the records in an object as shown above.