日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

jqgrid和ajax的区别,理解jqGrid的添加方法和Ajax请求

發(fā)布時間:2025/4/16 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 jqgrid和ajax的区别,理解jqGrid的添加方法和Ajax请求 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

我有一個現(xiàn)有的項目,我需要維護,但是這是我第一次滿足的jqGrid ...理解jqGrid的添加方法和Ajax請求

主要是,我有一個Product,即可以有多個Formule小號。每個Formule可以包含多個Period。 A Period由DepartureDate和Price來描述。

這是管理期間網(wǎng)格的代碼。特別是它增加了網(wǎng)格的導航器的可能性添加Period s。

當在網(wǎng)格中添加新行時,用戶填充包含2個字段的表單:DepartureDate和與新創(chuà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個參數(shù),包括日期和價格:

[HttpPost]

[AjaxRequestOnly]

[Transaction]

public JsonResult AddAjaxPeriod(Guid elementId, Guid formuleId,

DateTime departureDate, double price)

{ ... }

現(xiàn)在一切工作正常,直到我打開窗體中添加價格和日期,填空題要求的日期和價格,然后點擊驗證。

我得到一個錯誤,指出AddAjaxPeriod請求departureDate非可選參數(shù),不填寫的...我可以通過匿名方法達成一致,我填寫的elementId的formuleId設置在postData,但用戶嘗試添加的形式為departureData和price。有沒有辦法獲得“添加表單”(日期和價格)的值并將它們傳遞給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ù)字化實踐50位技術專家共同創(chuàng)作,文字、視頻、音頻交互閱讀

總結(jié)

以上是生活随笔為你收集整理的jqgrid和ajax的区别,理解jqGrid的添加方法和Ajax请求的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。