0
我有格式化工作日期和数字。由于某种原因,我的链接格式化程序仅中途中断。所有我在电网得到的是这样的链接:如果不被使用的baseLinkUrl设置(或包含)在URLjqgrid showLink不工作
?id=1
。
这里是我的JavaScript:
$(function() {
$("#d5d02a55-ba5e-46f2-a64a-05fd7870b273_list")
.jqGrid({
url: '/jqgrid2/getDataJson',
datatype: 'json',
mtype: 'GET',
colNames: ['Inv No', 'Date', 'Amount', 'Tax', 'Total', 'Notes'],
colModel: [{
"name": "invid",
"index": "invid",
"width": 55,
"formatter": "showlink",
"formatteroptions": {
"baseLinkUrl": "jsp/samplePage.jsp",
"target": "_blank",
"idName": "invid"
}
}, {
"name": "invdate",
"index": "invdate",
"width": 90,
"formatter": "date",
"formatteroptions": {
"srcformat": "yyyy-MM-dd",
"newformat": "MM/dd/yyyy"
}
}, {
"name": "amount",
"index": "amount",
"width": 80,
"align": "RIGHT",
"formatter": "number",
"formatteroptions": {
"decimalPlaces": 2
}
}, {
"name": "tax",
"index": "tax",
"width": 80,
"align": "RIGHT",
"formatter": "number",
"formatteroptions": {
"decimalPlaces": 2
}
}, {
"name": "total",
"index": "total",
"width": 80,
"align": "RIGHT",
"formatter": "number",
"formatteroptions": {
"decimalPlaces": 2
}
}, {
"name": "note",
"index": "note",
"width": 150,
"sortable": false
}
],
pager: '#d5d02a55-ba5e-46f2-a64a-05fd7870b273_pager',
rowNum: 5,
rowList: [5, 10, 25, 50],
sortname: 'invid',
sortorder: 'asc',
viewrecords: true,
multiselect: false,
gridview: true,
caption: '',
height: 'auto',
jsonReader: {
root: 'data',
page: 'currentPage',
total: 'totalPages',
records: 'totalRecords',
repeatitems: false,
id: 'id'
}
});
});
而且我的数据:
{ "currentPage" : "1",
"data" : [ { "amount" : 1000.0,
"invdate" : "2013-04-01 00:00:00",
"invid" : 1,
"note" : "No notes",
"tax" : 60.0,
"total" : 1060.0
},
{ "amount" : 200.0,
"invdate" : "2013-04-02 00:00:00",
"invid" : 2,
"note" : "",
"tax" : 12.0,
"total" : 212.0
},
{ "amount" : 500.0,
"invdate" : "2013-04-03 00:00:00",
"invid" : 3,
"note" : "",
"tax" : 30.0,
"total" : 530.0
},
{ "amount" : 400.0,
"invdate" : "2013-04-03 00:00:00",
"invid" : 4,
"note" : "Some notes",
"tax" : 24.0,
"total" : 424.0
},
{ "amount" : 200.0,
"invdate" : "2013-04-04 00:00:00",
"invid" : 5,
"note" : "",
"tax" : 12.0,
"total" : 2012.0
}
],
"limitRows" : "5",
"totalPages" : "3",
"totalRows" : "11"
}
我更正了格式选项拼写错误,更改了日期格式,并且所有格式都显示正在工作。大!我没有对id做jsonReader的更改,并且URL呈现正常。我不知道这是为什么? – 2013-04-29 18:18:02
@MichaelSobczak:你是否包含'key:true'属性?你确认你在第二页上有正确的ID吗?如果在网格中没有找到id,那么默认情况下将使用值1,2,3 ......(比如来自第一页的id)。 – Oleg 2013-04-29 19:23:24
我的示例数据的ID为1,2,3,所以我的测试无效。让我尝试添加“key”属性,并添加一行ID,该行在当前表中最后一个之后的几个项目中,以确保事情工作正常。谢谢你的提示! – 2013-04-29 21:46:02