2010-06-16 8 views
1

ASP.NET과 Jqgrid 3.7에서 테스트하고 있습니다. 파이어 폭스에서는 잘 작동하지만 IE에서는 그리드의 행이 표시되지 않습니다.Jqgrid 3.7은 인터넷 익스플로러에서 행을 표시하지 않습니다

웹 서비스의 응답

{"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 이전 버전,보고

하지 수있다
thegrid.addJSONData(JSON.parse(jsondata.responseText).d); 

jsonReader 대신 작동합니다.

답변

3

URL이 (http : // 또는 적어도 /로 시작)의 전체 경로는 이어야합니다. Internet Explorer는 상대 URL로 인해 많은 경우에 잘못 작동합니다.

좀 더 작은 일반적인 발언. loadBeforeSend을 사용하는 경우 ajaxGridOptions: { contentType: 'application/json; charset=utf-8' }을 사용할 수 있습니다. 일부 다른 기본값 (http://www.trirand.com/jqgridwiki/doku.php?id=wiki:colmodel_options 참조)도 제거 할 수 있습니다.

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

또한 당신은

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

에 JSON 데이터를 줄이고 jsonReader의 정의에 poperty 셀을 추가 할 수 있습니다 ""

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

당신은 확인할 수 http://www.ok-soft-gmbh.com/jqGrid/Jqgrid37.htmhttp://www.ok-soft-gmbh.com/jqGrid/Jqgrid37Comact.htm 모든 표준 웹 브라우저에서 문제없이 작동합니다.

+0

감사합니다. 그것은 매력처럼 작동합니다. 열쇠는 다음과 같습니다 : ajaxGridOptions : {contentType : 'application/json; charset = utf-8 '} –

관련 문제