0

This is my table generation codefor jqGrid 3.5.2

var jsonData = [{"KEY.ServiceId":"Service ID","KEY.ServiceDefinition":"Service Definition","KEY.Upload":"Upload","KEY.Download":"Download"}];
$('#' + id + 'Grid').jqGrid({
    datatype: 'json',                   
    rows : jsonData ,                   
    colNames: [ 'KEY.ServiceId',
                'KEY.ServiceDefinition',
                'KEY.Upload ',
                'KEY.Download'
    ],
    colModel: [
        { name: 'KEY.ServiceId', index: 'KEY.ServiceId', width: 135, sortable: false },
        { name: 'KEY.ServiceDefinition', index: 'KEY.ServiceDefinition', width: 175, sortable: false },     
        { name: 'KEY.Upload', index: 'KEY.Upload', width: 110, sortable: false },
        { name: 'KEY.Download', index: 'KEY.Download', width: 110, sortable: false }
    ],
    height:         '100',  
    scrollOffset:   0,
    loadComplete:   function(loadData) {                        
        if (loadData == null || loadData.rows == null || loadData.rows.length == null || loadData.rows.length <= 5) {                           
            $('#' + id + 'Grid').setGridHeight("auto");
        }
    },
    jsonReader: {
        repeatitems: false
    },
    loadui:         'disable',
    altRows:        true,
    viewrecords:    true,
    loadonce:       true,
    caption:        'My Caption'
}); 

However when I run it I do not get any error and table is empty.

EDIT: I have fixed my code and created a working fiddle example at here: http://jsfiddle.net/yNw3C/9668/ However it does not work with jqGrid 3.5.2?

kamaci
  • 72,915
  • 69
  • 228
  • 366

1 Answers1

0

You should set datatype: 'local' if you use local json object. And not rows, but data: jsonData.

Here is a great answer that mension other ways of solving your problem provided by Oleg.

Community
  • 1
  • 1
teo van kot
  • 12,350
  • 10
  • 38
  • 70
  • I tried what you said and here is a fiddle works for one of the latest versions of jqGrid: http://jsfiddle.net/yNw3C/9668/ However it does not work for jqGrid 3.5.2 Do you have any solution for it? – kamaci Dec 31 '14 at 09:39