我有一個這樣的形式:我的jqGrid的jqGrid:POST數據到服務器以抓取行數據(過濾和搜索)
<form id='myForm'>
<input type='text' name='search' />
<input type='text' name='maxPrice' />
</form>
和表:
<table id='myGrid'></table>
我需要張貼(不是GET)從myForm
到我的服務器方法的數據,以獲取行數據並填充網格。到目前爲止,我還沒有能夠讓jqGrid發佈任何東西。我仔細檢查了我的數據序列化,並正確地序列化了我的表單數據。這裏是我的jqGrid代碼:
$("#myGrid").jqGrid({
url: '/Products/Search") %>',
postData: $("#myForm").serialize(),
datatype: "json",
mtype: 'POST',
colNames: ['Product Name', 'Price', 'Weight'],
colModel: [
{ name: 'ProductName', index: 'ProductName', width: 100, align: 'left' },
{ name: 'Price', index: 'Price', width: 50, align: 'left' },
{ name: 'Weight', index: 'Weight', width: 50, align: 'left' }
],
rowNum: 20,
rowList: [10, 20, 30],
imgpath: gridimgpath,
height: 'auto',
width: '700',
//pager: $('#pager'),
sortname: 'ProductName',
viewrecords: true,
sortorder: "desc",
caption: "Products",
ajaxGridOptions: { contentType: "application/json" },
headertitles: true,
sortable: true,
jsonReader: {
repeatitems: false,
root: function(obj) { return obj.Items; },
page: function(obj) { return obj.CurrentPage; },
total: function(obj) { return obj.TotalPages; },
records: function(obj) { return obj.ItemCount; },
id: "ProductId"
}
});
你可以看到我做錯了什麼或應該做不同?
@Byron Sommardahl:你一週以來沒有對我的回答發表評論。你讀了我的答案嗎?它可以幫助你嗎?你的問題已經解決了嗎? – Oleg 2010-11-08 13:11:43
來自@Oleg的另一個令人敬畏的答案。 – 2012-06-25 19:03:55
@AJ .:我很高興舊的答案仍然有幫助。 – Oleg 2012-06-25 19:58:09