0

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<<<.

Waldemar
  • 5
  • 3

1 Answers1

0

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.

Mike Scotty
  • 10,530
  • 5
  • 38
  • 50
  • Hi Waldemar. Like I said, the server must send a JSON in the described form. It's no good to set recid on the grid. Each record must have a unique recid property. – Mike Scotty Apr 05 '16 at 20:12
  • Hi Mike, in my view I am getting a perfect json in response. Hence my surprise. I my code I set the recid to: recid: 'clmNumber', is that not good or enough ? But yes, there is no total and recid in the response. Do you think this is a problem ? – Waldemar Apr 05 '16 at 20:14
  • Anyway, I will follow your recommendation, and change the json structure and then test again. – Waldemar Apr 05 '16 at 20:47
  • Thanks Mike ! After correcting json format, I can see my data ! – Waldemar Apr 06 '16 at 20:50