我有這個來自AJAX調用的結果我想把它傳遞給jqgrid。格式與普通的jqgrid調用完全相同。我不知道爲什麼它不工作,任何幫助,不勝感激。Ajax數據結果到jqgrid顯示
{「page」:null,「total」:2,「records」:「16」,「rows」:[{「id」:「9910003」,「cell」:[「9910003」, 「DEMO3」, 「Test3的」, 「星期六,星期日」, 「8點○○分00秒」, 「17點○○分○○秒」, 「17」, 「0」]},{ 「ID」: 「9910004」,」細胞 「:[」 9910004" , 「DEMO4」, 「TEST4」, 「星期六,星期日」, 「8時00分00秒」, 「17時00分00秒」, 「19」, 「0」]},{」 ID 「:」 9910005" , 「細胞」: 「9910005」, 「DEMO5」, 「TEST5」, 「週六,週日」, 「08:00:00」, 「17:00:00」, 「17」, 「0」]},{ 「ID」: 「9910006」, 「細胞」:[ 「9910006」, 「DEMO6」, 「TEST6」, 「星期六,星期日」, 「8點00分零零秒」,「17:00 :00" , 「17」, 「0」]},{ 「ID」: 「9910007」, 「細胞」:[ 「9910007」, 「DEMO7」, 「TEST7」, 「星期六,星期日」,「8點:00" , 「十七時00分00秒」, 「14」, 「0」]},{ 「ID」: 「9910008」, 「細胞」:[ 「9910008」, 「DEMO8」, 「Test8」,「六孫 「 」21時00分零零秒「, 」6點00分00秒「, 」19「, 」0「]},{ 」ID「: 」9910009「, 」細胞「:[ 」9910009「,」 DEMO9 」, 「Test9」, 「星期六,星期日」, 「二十一點00分○○秒」, 「6點00分00秒」, 「14」, 「0」]},{ 「ID」: 「9910010」, 「細胞」 :[ 「9910010」, 「DEMO10」, 「Test10」, 「星期六,星期日」, 「21時00分零零秒」, 「六點00分00秒」, 「14」, 「0」]},{ 「ID」 「9910011」, 「細胞」:[「9910 011" , 「DEMO11」, 「TEST11」, 「星期六,星期日」, 「21點00分零零秒」, 「六時00分00秒」, 「14」, 「0」]},{ 「ID」:「9910012 」, 「細胞」:[ 「9910012」, 「DEMO12」, 「TEST12」, 「星期六,星期日」, 「21點00分○○秒」, 「6時零零分00秒」, 「17」, 「0」]} { 「ID」: 「9910013」, 「細胞」: 「9910013」, 「DEMO13」, 「Test13」, 「週六,週日」, 「21:00:00」, 「06:00:00」,」 16" , 「0」]},{ 「ID」: 「9910014」, 「細胞」:[ 「9910014」, 「DEMO14」, 「Test14」, 「星期六,星期日」, 「21時00分00秒」,」 6時00" 分00秒, 「14」, 「0」]},{ 「ID」: 「9910015」, 「細胞」:[ 「9910015」, 「DEMO15」, 「Test15」, 「星期六,星期日」,」 21時00" 分○○秒, 「6點00分00秒」, 「14」, 「0」]},{ 「ID」: 「9910016」, 「細胞」:[ 「9910016」, 「DEMO16」, 「TEST16」 「週六,週日」, 「21:00:00」, 「06:00:00」, 「14」, 「0」]}]}
下面是我的全碼:
function report_grid() {
$.ajax({
type: "POST",
url: "filter_option.php?action=filter",
data: $('#form1').serialize(),
success: function(rdata) {
jQuery("#report-grid").jqGrid({
data: rdata,
datatype: "local",
colNames:['Emp ID','firstName', 'surName', 'restDay','shift_In','shift_Out','late','undertime'],
colModel:[
{name:'emp_id',index:'emp_id', width:55},
{name:'firstname',index:'firstname', width:90},
{name:'surname',index:'surname', width:100},
{name:'restday',index:'restday', width:80, align:"right"},
{name:'shift_in',index:'shift_in', width:80, align:"right"},
{name:'shift_out',index:'shift_out', width:80,align:"right"},
{name:'late',index:'late', width:150, sortable:false},
{name:'ut',index:'ut', width:150, sortable:false},
],
height: 'auto',
width: 'auto',
rowNum:10,
rowList:[10,15,20,30,50],
pager: '#report-pager',
sortname: 'emp_id',
viewrecords: true,
sortorder: "desc",
caption:"Timesheet Summary"
});
jQuery("#report-grid").jqGrid('navGrid','#report-pager',{edit:false,add:false,del:false});
}
})
}
我在下面嘗試但沒有成功,我想我失去了一些東西
data:rdata.rows
datatype:"local" // shows only the id but with correct number of records
data:rdata.rows
datatype: "json" // shows nothing at all.