我想用ajax,jQuery mobile和spring mvc來顯示數據庫中的數據。jqgrid可以使用jQuery移動嗎?
示例:顯示錶中的課程名稱列表。
我現在使用jqgrid來顯示數據,但有沒有其他的選擇,而不使用數據?有很多在論壇上,但大多使用PHP,但我使用彈簧mvc控制器。
請人幫助我..
我想用ajax,jQuery mobile和spring mvc來顯示數據庫中的數據。jqgrid可以使用jQuery移動嗎?
示例:顯示錶中的課程名稱列表。
我現在使用jqgrid來顯示數據,但有沒有其他的選擇,而不使用數據?有很多在論壇上,但大多使用PHP,但我使用彈簧mvc控制器。
請人幫助我..
不知道是否jqGrid的工作與jQuery Mobile的,但對於一個正常的Web應用程序,你可以使用addJSONData
法jsonReader
和datatype
屬性設置爲一個功能。下面是一個示例:
function cfgWixGenApplicationsGrid() {
var cond = null;
$("#tblWixGenApplications").jqGrid({
datatype: function (postdata) {
var orderByExpr = "";
if (postdata.sidx != "") {
orderByExpr = postdata.sidx + " " + postdata.sord;
}
getPageList(cond, postdata.page, postdata.rows, orderByExpr, hSuccPageWixGenApplications, hError);
},
colNames: ["Id", "Title", "Name", "Version", "MainAssemblyName"
],
colModel: [
{ name: "Id", index: "Id", width: 50, sorttype: "String", editable: false },
{ name: "Title", index: "Title", width: 50, sorttype: "String", editable: true },
{ name: "Name", index: "Name", width: 50, sorttype: "String", editable: true },
{name: "Version", index: "Version", width: 50, sorttype: "String", editable: true },
{name: "MainAssemblyName", index: "MainAssemblyName", width: 50, sorttype: "String", editable: true }
],
multiselect: false,
pager: "#divPagerWixGenApplications",
viewrecords: true,
jsonReader: { repeatitems: false, root: "rows", page: "page", records: "records", total: "total" },
rowNum: 10,
rowList: [10, 20, 30]
});
}
的getPageList
做一個Ajax調用,在我的情況下WCF服務。我想你可以在這裏調用MVC網址。
的hSuccPageWixGenApplications
函數調用addJSONData
這樣的:
function hSuccPageWixGenApplications(pageData) {
var list = [];
$.each(pageData.List, function (index, value) {
if (!value.IsDeleted) {
list.push(value);
}
});
var grid = $("#tblWixGenApplications")[0];
var pData = new Object();
var recCount = pageData.RecordCount == null ? 1000 : pageData.RecordCount;
pData.page = pageData.PageNo;
pData.records = recCount;
pData.rows = list;
pData.total = recCount/pageData.PageSize;
grid.addJSONData(pData);
};
但我需要做一個移動應用程序..這就是爲什麼我使用jquerymobile ..我讀了一些他們說jqgrid可以在手機中使用,但大多數使用php的例子.. – sone
你可以開始[ 「接受」]在你前面的問題(http://meta.stackexchange.com/a/5235/147495)的答案。 – Oleg