我是jqGrid的第一次用戶,到目前爲止,我去槽官方的例子,我有興趣使用json將數據加載到網格。jQuery加載數據到jqGrid
我目前看,加載數據(JSON數據): http://trirand.com/blog/jqgrid/jqgrid.html
這裏是一些JavaScript創建網格:
jQuery("#list2").jqGrid(
{
url : '<c:url value="${webappRoot}/getdetails" />',
datatype : "json",
colNames : [ 'id', 'Location', 'Country Code', 'Type', 'Interval',
'Version', 'Last Active', 'Last Login', 'NOTE' ],
colModel : [
{ name : 'id', width : 10 },
{ name : 'location', width : 75 },
{ name : 'countryCode', width : 50 },
{ name : 'type', width : 40 },
{ name : 'interval', width : 30 },
{ name : 'version', width : 45 },
{ name : 'lastactive', width : 50, align : "right" },
{ name : 'lastlogin', width : 50, sortable : false },
{ name : 'note', width : 50, sortable : false}
],
rowNum : 10,
rowList : [ 10, 20, 30 ],
pager : '#pager2',
width: gridWidth,
sortname : 'id',
viewrecords : true,
sortorder : "desc",
caption : "JSON Example"
});
jQuery("#list2").jqGrid('navGrid', '#pager2',
{ edit : false, add : false, del : false});
${webappRoot}/getdetails
轉換路徑到我的項目像http://localhost/myProject/getdetails
,我使用的是Spring MVC(它可能無關緊要)。
當我看着螢火蟲這會產生這樣的HTTP請求:
GET http://localhost/newProject/getdetails?_search=false&nd=1304638787511&rows=10&page=1&sidx=id&sord=desc
200 OK
135ms
這裏是迴應:
{
"id": 1,
"location": "office_2782",
"countryCode": "UK",
"quarter": "500",
"version": "v3.05",
"lastactive": "yesterday",
"lastlogin": "today",
"note": "no note",
"type": "read-only"
}
當我瀏覽到JSON選項卡這一切似乎與此相同,任何想法是什麼我做錯了?
我想加載只有一個記錄開始,我不能得到它的工作,任何幫助appriciated。
如果你在墨爾本找到自己,給我發消息,我會給你買一瓶冰鎮啤酒。這是一個有益的總結。 – 2011-11-01 10:39:27
@DuncanBayne:好建議!我認爲啤酒在亞熱帶墨爾本飲用非常好。我很高興能夠幫助你,但我不確定,我曾經去過澳大利亞。不過謝謝你的建議! – Oleg 2011-11-01 11:17:33
非常好,詳細的答案。謝謝哥們。 – 2016-01-26 11:11:39