2017-02-14 15 views
0

내있는 jqGrid 코드는 아래있는 jqGrid는

jQuery("#jqgrid").jqGrid({ 

mtype: 'GET', 
datatype: "json", 
height: '350', 
colNames: ['<%=Resources.Resource.Action%>','uid', '<%=Resources.Resource.Fullname%>', '<%=Resources.Resource.Username%>', '<%=Resources.Resource.Group%>', '<%=Resources.Resource.Status%>', '<%=Resources.Resource.JoinedDate%>', '<%=Resources.Resource.LastLoginDate%>', '<%=Resources.Resource.LastLoginIp%>'], 
colModel: [ 
    { name: 'act', index: 'act', sortable: false }, 
    { name: 'uid', index: 'uid' }, 
    { name: 'userfullname', index: 'userfullname' }, 
    { name: 'username', index: 'username' }, 
    { name: 'MemberGroup', index: 'MemberGroup', editable: true }, 
    { name: 'Status', index: 'Status', align: "right", editable: true }, 
    { name: 'JoinDate', index: 'JoinDate', align: "right", editable: true, editable: true, sorttype: "date", unformat: pickDate }, 
    { name: 'LastLoginDate', index: 'LastLoginDate', align: "right", editable: true, editable: true, sorttype: "date", unformat: pickDate }, 
    { name: 'LoginIp', index: 'LoginIp', sortable: false, editable: true }], 
jsonreader: { 
    repeatitems: false, root: 'rootUser', 
    id: 'uid', 
    page: function(obj) { return 1; }, 
    total: function(obj) { return 1; }, 
    records: function (obj) { return obj.rootUser.length; }, 

}, 
rowNum: 10, 
rowList: [10, 20, 30], 
pager: '#pager_jqgrid', 
sortname: 'uid', 
rownumbers: true, 
toolbarfilter: true, 
viewrecords: true, 
sortorder: "asc", 
gridComplete: function() { 
    var ids = jQuery("#jqgrid").jqGrid('getDataIDs'); 
    for (var i = 0; i < ids.length; i++) { 
     var cl = ids[i]; 
     be = "<button class='btn btn-xs btn-default btn-quick' title='Edit Row' onclick=\"showPanelPlayer()\"><i class='fa fa-pencil'></i></button>"; 
     //se = "<button class='btn btn-xs btn-default btn-quick' title='Save Row' onclick=\"jQuery('#jqgrid').saveRow('" + cl + "');\"><i class='fa fa-save'></i></button>"; 
     //ca = "<button class='btn btn-xs btn-default btn-quick' title='Cancel' onclick=\"jQuery('#jqgrid').restoreRow('" + cl + "');\"><i class='fa fa-times'></i></button>"; 
     //jQuery("#jqgrid").jqGrid('setRowData', ids[i], { act: be + se + ca }); 
     jQuery("#jqgrid").jqGrid('setRowData', ids[i], { act: be }); 
    } 
}, 
editurl: "ajax/dummy-jqtable.html", 
caption: "<%=Resources.Resource.MemberListing%>", 
multiselect: true, 
autowidth: true, 

}) 비어 그리드를 보여주는 JSON 데이터를로드 할 수 없습니다

제출 버튼을 클릭하면 백엔드 페이지가 호출되어 Json이 생성됩니다. 버튼 코드를 제출 내

는 백 엔드에서

function showPanel() {      
    var UserName = document.getElementById('txtUser').value;     
    $('#jqgrid').setGridParam({ url: 'ListUser.aspx?cmd=LoadUser&UN=' + UserName }).trigger('reloadGrid'); 
} 

json으로 돌아갑니다 내가 직면하고있는 문제는 내 그리드 쇼 비어

{"rootUser":[{"uid":1,"userfullname":"Johnson","username":"Deng","MemberGroup":0,"Status":1,"JoinDate":new Date(1487058713667),"LastLoginDate":new Date(1487058713667),"LoginIp":""},{"uid":2,"userfullname":"James Abb","username":"James","MemberGroup":0,"Status":1,"JoinDate":new Date(1487058713667),"LastLoginDate":new Date(1487058713667),"LoginIp":""}]} 

이다, 아무것도 난 내 코드를 형성 놓치고 있다는 것입니다 ?

답변

0

"JoinDate": new Date(1487058713667)과 같은 사용 필드 때문에 입력 데이터가 JSON 형식이 아닙니다. 여기에서 JSON 데이터의 유효성을 검사 할 수 있습니다 : http://jsonlint.com/. 문제는 jqGrid (free jqGrid, 상업용 Guriddo jqGrid JS 또는 버전 < = 4.7의 이전 jqGrid)의 포크에서 사용하는 jqGrid의 버전에 따라 달라집니다. 예를 들어 무료 jqGrid를 사용하면 을 사용하여 "JoinDate": 1487058713667에서 14-Feb-2017 08:51:53까지의 데이터를 구문 분석 할 수 있습니다. 다른 원인으로는 newformat을 사용할 수 있습니다.

setRowData이라고하는 곳에서 루프와 함께 gridComplete을 절대 사용하지 말 것을 권장합니다. 맞춤형 포맷터 또는 formatter: actions의 사용이 훨씬 더 효과적입니다.

+0

모든 datetime 값을 제거한 후에는 아무 것도 표시되지 않습니다. –

+0

@abccba : 문제를 재현하는 데모를 제공해야합니다. 나는 대답을 게시하기 전에 나의 제안을 테스트했다. formatatter : {srcformat : "u1000", newformat : "dMY H : i"에 대한 형식 데이터 : "JoinDate": 1487058713667'에 대해'14-Feb-2017 08 : 51 : 53'을 볼 수있었습니다. : s "}'. 나는 내 테스트에서 무료 jqGrid 4.13.6을 사용했다. – Oleg