簡體   English   中英

使用本地數據的jqgrid僅顯示一行

[英]jqgrid using local data only displays one row

我在搜索結果頁面上遇到了麻煩。 搜索頁面有16個輸入,結果頁面使用動態查詢來獲取結果並將它們輸入到一個數組中,該數組用於json_encode來用結果填充jqgrid。 但是,網格僅顯示第一條記錄。 我在頁面上添加了一個php“ echo json_encode()...”腳本,以查看json格式的結果,並顯示了搜索結果中的所有記錄,所以我不知道為什么網格只顯示第一個行。 我很樂意為此提供任何幫助。 這是網格的腳本(我不包括動態查詢或數組腳本,因為它們工作正常):

$(document).ready(function () {
$("#slist").jqGrid({
data: "srchres",
datatype: "local",
mtype: "GET",
colNames: ['ProjectID', 'Customer Name', 'Invoice Number', 'Vehicle Info.', 'Project Date'],
colModel: [
{name:'ProjectID', index:'ProjectID', align:'right', hidden:true, editable:false},
{name:'CustomerName', index:'CustomerName', editable:false, width:175, align:'center'},
{name:'InvoiceNumber', index:'InvoiceNumber', editable:false, width:175, align:'center'},
{name:'VehicleInfo', index:'VehicleInfo', width:350, align:'left', editable:false},
{name:'ProjectDate', index:'ProjectDate', editable:false, width:125, align:'center', formatter: 'date', formatoptions: { newformat: 'm/d/Y' }},
],
jsonReader: {repeatitems: false, id: "ProjectID"},
onSelectRow: function (rowid) {
var rowData = $(this).getRowData(rowid);
document.location.href = "../manageproject.php?pid=" + rowData['ProjectID'];
},
pager: "#spager",
loadonce: true,
rowNum: 20,
rowList: [],
width: "auto",
height: "auto",
caption: "",
sortname: "",
sortorder: "",
viewrecords: true,
gridview: true
});
var srchres = <?php echo json_encode($projects_array); ?>;
for(var i=0;i<srchres.length;i++)
jQuery("#slist").addRowData(srchres[i].id,srchres[i]);
});

在網格中嘗試以下設置:

$(document).ready(function () {
    var srchres = <?php echo json_encode($projects_array); ?>;
    $("#slist").jqGrid({
        data: srchres,
        datatype: "local",
        ....
    });
...

});

注意變量srchres以及如何在網格選項中定義。 不需要使用addRowData。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM