By iñaki


2010-06-16 14:57:07 8 Comments

I'm testing with ASP.NET and Jqgrid 3.7, in firefox it works fine but in IE it does not show any row in the grid.

The response from the webservice is

{"d":
    {"__type":"jqGrid",
     "total":"1",
     "page":"1",
     "records":"10",
     "rows":[
         {"id":"180","cell":["180","Cultura"]},
         {"id":"61","cell":["61","Deporte"]},
         {"id":"68","cell":["68","Deporte"]},
         {"id":"5","cell":["5","Economía"]},
         {"id":"67","cell":["67","Economía"]},
         {"id":"76","cell":["76","Economía"]},
         {"id":"178","cell":["178","Economía"]},
         {"id":"4","cell":["4","Entrevista"]},
         {"id":"66","cell":["66","Entrevista"]},
         {"id":"78","cell":["78","Entrevista"]}
     ]
    }
}

and the call is

myGrid = $("#list").jqGrid({
    url: 'ws/WsNoticias.asmx/jqObtenerTemas',
    datatype: 'json',
    mtype: 'GET',
    loadBeforeSend: function(XMLHttpRequest) {
        XMLHttpRequest.setRequestHeader("Content-Type", "application/json");
    },
    colNames: ['Id', 'Nombre'],
    colModel: [
        {name: 'Id', index: 'Id', width: 20, align: 'left', editable: false},
        {name: 'Nombre', index: 'Nombre', width: 200, align: 'left', editable: false}
    ],
    rowNum: 10,
    rowList: [5, 10, 200],
    sortname: 'Nombre',
    sortorder: "asc",
    pager: $("#listp"),
    viewrecords: true,
    caption: '',
    width: 600,
    height: 250,
    jsonReader: {
        root: "d.rows",
        page: "d.page",
        total: "d.total",
        records: "d.records"
    }
});

I can't see where is the issue ..., with versions prior to 3.6 and with

thegrid.addJSONData(JSON.parse(jsondata.responseText).d);

instead of jsonReader it works.

1 comments

@Oleg 2010-06-17 12:43:05

You should just use the full path in URL (started with http:// or at least with /) first of all. Internet Explorer works wrong in a lot of cases with relative urls.

Some more small general remarks. You can use ajaxGridOptions: { contentType: 'application/json; charset=utf-8' } unstead of using loadBeforeSend. Some other default values (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:colmodel_options) can be also removed.

myGrid = $("#list").jqGrid({
    url: 'http://www.ok-soft-gmbh.com/jqGrid/Jqgrid37json.txt',
    datatype: 'json',
    mtype: 'GET',
    ajaxGridOptions: { contentType: 'application/json; charset=utf-8' },
    colModel: [
        { name: 'Id', width: 20 },
        { name: 'Nombre', width: 200 }
    ],
    rowNum: 10,
    rowList: [5, 10, 200],
    sortname: 'Nombre',
    sortorder: "asc",
    pager: $("#listp"),
    viewrecords: true,
    width: 600,
    height: 250,
    jsonReader: {
        root: "d.rows",
        page: "d.page",
        total: "d.total",
        records: "d.records"
    }
});

Moreover you can reduce the JSON data to

{"d":
    {"__type":"jqGrid",
     "total":"1",
     "page":"1",
     "records":"10",
     "rows":[
         ["180","Cultura"],
         ["61","Deporte"],
         ["68","Deporte"],
         ["5","Economía"],
         ["67","Economía"],
         ["76","Economía"],
         ["178","Economía"],
         ["4","Entrevista"],
         ["66","Entrevista"],
         ["78","Entrevista"]
     ]
    }
}

and add in the definition of the jsonReader the poperty cell: "":

jsonReader: {
    root: "d.rows",
    page: "d.page",
    total: "d.total",
    cell: "",
    records: "d.records"
}

You can verify http://www.ok-soft-gmbh.com/jqGrid/Jqgrid37.htm and http://www.ok-soft-gmbh.com/jqGrid/Jqgrid37Comact.htm that all works without any problem in all standard web browsers.

@iñaki 2010-06-18 13:20:47

Thank you, it works like a charm. The key is: ajaxGridOptions: { contentType: 'application/json; charset=utf-8' }

Related Questions

Sponsored Content

3 Answered Questions

[SOLVED] jqGrid grouping feature disappear when run addRowData

  • 2011-10-26 13:52:14
  • Yang Bo
  • 1127 View
  • 0 Score
  • 3 Answer
  • Tags:   jqgrid

1 Answered Questions

[SOLVED] How to get the particular cell value in JQgrid

1 Answered Questions

1 Answered Questions

[SOLVED] Read editable input values in jqgrid

  • 2012-08-28 13:19:55
  • user200340
  • 3383 View
  • 2 Score
  • 1 Answer
  • Tags:   jquery jqgrid

2 Answered Questions

[SOLVED] How to show grid with root in jqGrid in JSON

  • 2012-06-29 01:55:46
  • Ovilia
  • 4085 View
  • 0 Score
  • 2 Answer
  • Tags:   jquery json jqgrid

2 Answered Questions

how to pass java beans to jsp page for jqQrid to display using json?

  • 2009-09-17 23:22:30
  • mango
  • 2810 View
  • 1 Score
  • 2 Answer
  • Tags:   java json jqgrid

1 Answered Questions

[SOLVED] Search is not working with filter toolbar in JQGrid

  • 2011-04-04 08:16:55
  • Saleemuddin Mewati
  • 4106 View
  • 2 Score
  • 1 Answer
  • Tags:   search jqgrid

1 Answered Questions

[SOLVED] jqGrid colModel and jsonReader with no cell

  • 2010-10-04 18:59:14
  • Travis Heseman
  • 1935 View
  • 0 Score
  • 1 Answer
  • Tags:   jquery json jqgrid

4 Answered Questions

Sponsored Content