jqGrid的3.7不显示在Internet Explorer中的行 [英] Jqgrid 3.7 does not show rows in internet explorer

查看:92
本文介绍了jqGrid的3.7不显示在Internet Explorer中的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我与ASP.NET和jqGrid的3.7测试,在Firefox它工作正常,但在IE中不显示网格中的任何一行。

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.

从web服务的响应

{"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"]}
     ]
    }
}

和呼叫

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"
    }
});

我看不到的地方之前是问题......,随着版本3.6,以

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

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

而不是jsonReader的工作原理。

instead of jsonReader it works.

推荐答案

您应该只使用充满URL路径(开始以http://或至少/)首先。 Internet Explorer的工作错了很多相对URL的案件。

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.

一些更加小巧的一般性意见。您可以使用 ajaxGridOptions:{的contentType:应用/ JSON的;字符集= utf-8'} unstead使用 loadBeforeSend 。其他一些默认值(见 http://www.trirand.com/jqgridwiki /doku.php?id=wiki:colmodel_options )也可以除去。

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"
    }
});

此外,您可以减少JSON数据

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"]
     ]
    }
}

和添加在 jsonReader 的poperty细胞的定义:

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"
}

您可以验证 http://www.ok-soft-gmbh.com /jqGrid/Jqgrid37.htm HTTP://www.ok- soft-gmbh.com/jqGrid/Jqgrid37Comact.htm 是没有任何问题的所有作品中的所有标准Web浏览器。

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.

这篇关于jqGrid的3.7不显示在Internet Explorer中的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆