我正在開發一個KendoUI網格,內嵌可編輯選項在JavaScript中,並且無法使更新按鈕觸發單擊事件並將數據發佈到服務器端更新事件。點擊更新按鈕甚至不會更新客戶端上的網格。Kendo UI網格更新按鈕沒有觸發
希望有人能幫助我指出我在這裏做錯了什麼。
這不是重複的,因爲我厭倦了答案中的jfiddle鏈接,它不工作。 kendo UI grid update function wont fire
<div id="grid"></div>
@section Scripts{
<script type="text/javascript">
$(function() {
var dataSource = new kendo.data.DataSource({
transport: {
read: {
url: "Home/GetPupilsAsJson",
dataType: 'json'
},
update: {
url: "Home/UpdatePupils",
dataType: 'json',
type: 'POST'
}
},
pageSize: 5,
autoSync: true
});
$('#grid').kendoGrid({
dataSource: dataSource,
editable: "inline",
pageable: true,
columns: [{
field: "Id",
title: "Id",
width: 150,
hidden: true
}, {
field: "Firstname",
title: "Firstname",
width: 150
}, {
field: "Lastname",
title: "Lastname",
width: 150
}, {
field: "DateOfBirth",
title: "DateOfBirth",
width: 150
}, {
field: "Class",
title: "Class",
width: 150
}, {
field: "Year",
title: "Year",
width: 150
},
{
command: ["edit"],
width: 150
}]
});
});
</script>
}
的HomeController
public ActionResult GetPupilsAsJson()
{
return Json(GetPupils(), JsonRequestBehavior.AllowGet);
}
[AcceptVerbs(HttpVerbs.Post)]
[HttpPost]
public void UpdatePupils(Pupil p)
{
//never reach here
}
你可以在UpdatePupils中試試沒有參數'Pupil p'並告訴我程序到達了嗎? – MustafaP
@MustafaP ..我厭倦了你的建議,仍然無法正常工作。事實上,我的問題是更新按鈕甚至沒有關閉客戶端上的編輯字段。我嘗試用MVC包裝它工作正常,但我們沒有許可證的包裝不幸的。 – lawphotog
如果您的瀏覽器處於'Developer Mode'或'inspection'並且您檢查網絡流量,您是否看到有任何請求會看到請求通過?我的意思是,你的瀏覽器調用'Home/UpdatePupils'嗎? – OnaBai