をキャンセル:でMVC Telerikグリッドこれは私Telerikグリッドコードで更新AJAX要求
function Grid_OnRequestStart(e) {
if (e.name == "update") {
alert(e.dataItem.DistTo + " - " + $("#DistTo").val());
if (confirm("Are you sure?")) {
alert("Distribution was updated!");
}
else {
// Here I want to cancel the update request
}
}
}
:
@(Html.Telerik().Grid(Model).Name("DistributionGrid").DataKeys(dataKeys => dataKeys.Add("DistributionID")).
ToolBar(toolBar => toolBar
.Template(@<text>
@{
<b>Distribution</b>
<ul class='ul-bulk-menu'>
<li><button id='newDistribution' class='t-button t-button-icon' title='New Distribution'><span>Add Distribution</span></button></li>
</ul>
}
</text>))
.Columns(c =>
{
c.Command(command =>
{
command.Edit().ButtonType(GridButtonType.Image).HtmlAttributes(new { title = "Edit Distribution"});
command.Delete().ButtonType(GridButtonType.Image).HtmlAttributes(new { title = "Delete Distribution" });
}).Width(100);
c.Bound(o => o.DistTo);
c.Bound(o => o.DistCC);
})
.Scrollable(o => o.Height(440))
.Resizable(o => o.Columns(true))
.Reorderable(o => o.Columns(true))
.DataBinding(o => o.Ajax()
.Select("SelectDist", "Mail")
.Update("UpdateDist", "Mail")
.Delete("DeleteDist", "Mail")
)
.Editable(editing => editing.Mode(GridEditMode.InForm))
.ClientEvents(events => events.OnCommand("Grid_OnRequestStart"))
)
</div>
私はjQueryのは、次のコードを使用してjQueryのを使用して "更新" 機能を中断してい"else"オプションAJAXの "update"リクエストを取り消したい。
可能ですか?
ありがとうございます!
すぐにお返事ありがとうございます。 実際には、この行を使って私は次のエラーを受け取りました: "VM466:43未知の型エラー:e.set_enableAjaxは関数ではありません"。 しかし、AJAX関数の実行が停止されました。 – Lena
@Lena Hmm、ok、 'set_cancel(true);'メソッドを試してみることができますか? – woodykiddy
エラー:「未捕捉ReferenceError:set_cancelが定義されていません」 – Lena