jqgrid和ajax的区别,理解jqGrid的添加方法和Ajax请求
我有一個(gè)現(xiàn)有的項(xiàng)目,我需要維護(hù),但是這是我第一次滿足的jqGrid ...理解jqGrid的添加方法和Ajax請(qǐng)求
主要是,我有一個(gè)Product,即可以有多個(gè)Formule小號(hào)。每個(gè)Formule可以包含多個(gè)Period。 A Period由DepartureDate和Price來(lái)描述。
這是管理期間網(wǎng)格的代碼。特別是它增加了網(wǎng)格的導(dǎo)航器的可能性添加Period s。
當(dāng)在網(wǎng)格中添加新行時(shí),用戶填充包含2個(gè)字段的表單:DepartureDate和與新創(chuàng)建的期間相對(duì)應(yīng)的Price。
jQuery("#periode-grid").jqGrid(
'setGridParam',
{
postData: {
formuleId: rowid // <<< !!!
},
datatype: "json"
})
.navGrid("#periode-pager",
{
"edit": false, "add": true, "del": false,
"search": true, "addtext": "@Resources.Main.Grid_Add"
},
{},
{
"url": '@Url.Action("AddAjaxPeriod",
new { elementId = @ViewData["ProductId"] })', // <<< !!!
"closeOnEscape": true, "closeAfterAdd": true,
"reloadAfterSubmit": true, "width": 500,
"beforeSubmit": BeforeFormuleSubmit
});
,這是我AddAjaxPeriod簽名,包含4個(gè)參數(shù),包括日期和價(jià)格:
[HttpPost]
[AjaxRequestOnly]
[Transaction]
public JsonResult AddAjaxPeriod(Guid elementId, Guid formuleId,
DateTime departureDate, double price)
{ ... }
現(xiàn)在一切工作正常,直到我打開(kāi)窗體中添加價(jià)格和日期,填空題要求的日期和價(jià)格,然后點(diǎn)擊驗(yàn)證。
我得到一個(gè)錯(cuò)誤,指出AddAjaxPeriod請(qǐng)求departureDate非可選參數(shù),不填寫的...我可以通過(guò)匿名方法達(dá)成一致,我填寫的elementId的formuleId設(shè)置在postData,但用戶嘗試添加的形式為departureData和price。有沒(méi)有辦法獲得“添加表單”(日期和價(jià)格)的值并將它們傳遞給AddAjaxPeriod方法?
編輯:
的奧列格發(fā)言后,我發(fā)現(xiàn)網(wǎng)格初始化(在occurence在母體部分視圖)。這是代碼:
jQuery("#periode-grid").jqGrid({
"url": '@Url.Action("PeriodePagedList", new { elementId = ViewData["ProductId"] })',
"datatype": 'local',
"mtype": 'POST',
"width": 400,
"height": 100,
"colNames": [
"@Resources.Catalog_Products.FormulePeriode_DepartureDate",
"@Resources.Catalog_Products.FormulePeriode_Price",
"" // Actions
],
"colModel": [
{ "name": 'DepartureDate', "index": 'DepartureDate', "editable": true, "align": 'center', "width": 100, "sorttype": 'date', "datefmt": 'dd/mm/yyyy', "editoptions": { "dataInit": function (element) { jQuery(element).datepicker({ "dateFormat": 'dd/mm/yy', "minDate": 0, "showAnim": '' }) } }, "editrules": { "required": true, "date": true } },
{ "name": 'Price', "index": 'Price', "editable": true, "align": 'center', "editrules": { "required": true }, "width": 100, "formatter": currencyFormatter, "unformat": unformatCurrency },
{ "name": 'Actions', "index": 'Actions', "width": 50, "align": 'center', "search": false, "sortable": false }
],
"sortname": 'DepartureDate',
"rowNum": 100,
"loadComplete": OnLoadPeriodeComplete,
"pager": jQuery('#periode-pager'),
"pginput": false,
"pgbuttons": false,
"viewrecords": false,
"imgpath": '@Url.Content("~/Content/jqueryui/images")',
"caption": "@Resources.Catalog_Products.FormulePeriode_GridTitle",
"shrinkToFit": true,
"hidegrid": false
});
2014-02-20
Serge
《新程序員》:云原生和全面數(shù)字化實(shí)踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀總結(jié)
以上是生活随笔為你收集整理的jqgrid和ajax的区别,理解jqGrid的添加方法和Ajax请求的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 计算机显示器不清楚跟电池有关系吗,电脑液
- 下一篇: win服务器上文件消失,Winserve