我有两个网格。当首先从其他网格中选择行时,用户可以正确创建新行。如果第一个没有选择行,javascript 中的一个功能警告但不能阻止打开弹出窗口。我需要如何防止或如何关闭网格弹出窗口
两格
//grid code in view
@(Html.Kendo().Grid<Kurslar.Models.DonemKursu>()
.Name("donemGrid")
.Columns(columns =>
{
columns.Bound(p => p.DersAdi).Title("Ders").Width(85);
columns.Bound(p => p.EgitmenAdiSoyadi).Title("Eğitmen").Width(200);
columns.Bound(p => p.SinifKontenjanSayisi).Title("Kontenjan").Width(80);
columns.Bound(p => p.DonemBaslangicBitis).Title("Dönem").Width(157);
columns.Bound(p => p.DonemId).Visible(false);
columns.Bound(p => p.DersId).Visible(false);
columns.Bound(p => p.EgitmenId).Visible(false);
columns.Command(command => { command.Edit().Text("Güncelle"); command.Destroy().Text("Sil"); }).Width(164);
})
.Pageable()
.Sortable()
.Selectable()
.HtmlAttributes(new { style = "max-width:700px", id = "donemGrid" })
.Editable(editable => editable.Mode(GridEditMode.PopUp)
.Window(conf => conf.Title("Yeni Kurs"))
.TemplateName("DonemKursuTemplate"))
.ToolBar(toolbar => toolbar.Create().Text("Kurs Ekle"))
.Events(e => e.Edit("onEdit").Change("change"))
.DataSource(dataSource => dataSource
.Ajax()
.Read("GridDonemKurslari", "Tanim")
.Create(create => create.Action("DonemKursuOlustur", "Tanim"))
.Update(update => update.Action("DonemKursuGuncelle", "Tanim"))
.Destroy(destroy => destroy.Action("DonemKursuSil", "Tanim"))
.PageSize(20)
.Model(model => model.Id(p => p.DonemId))
)
)
</td>
<td style="vertical-align:top;max-width:600px">
<h4>Sınıflar</h4>
@(Html.Kendo().Grid<Kurslar.Models.DonemKursSinifi>()
.Name("sinifGrid")
.Columns(columns =>
{
columns.Bound(p => p.Tanim).Width(50).Title("Tanim");
columns.Bound(p => p.DersAdi).Width(50).Title("Ders");
columns.Bound(p => p.EgitmenAdiSoyadi).Width(50).Title("Eğitmen");
columns.Bound(p => p.KontenjanSayisi).Width(50).Title("Kontenjan");
columns.Bound(p => p.DonemBaslangicBitis).Width(50).Title("Dönem");
columns.Bound(p => p.TarifeId).Width(50).Title("Tarife");
columns.Bound(p => p.DonemId).Visible(false);
columns.Bound(p => p.DersId).Visible(false);
columns.Bound(p => p.EgitmenId).Visible(false);
columns.Command(command => { command.Edit().Text("Güncelle"); command.Destroy().Text("Sil"); }).Width(180);
})
.Pageable()
.Sortable()
.AutoBind(false)
.Editable(editable => editable.Mode(GridEditMode.PopUp)
.Window(conf => conf.Title("Yeni Sınıf"))
.TemplateName("DonemKursSinifiTemplate"))
.Name("pencere")
.ToolBar(toolbar => toolbar.Create().Text("Sınıf Ekle"))
.Events(e => e.Edit("onEditSinif"))
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("GridDonemKursSinifi", "Tanim").Data("data"))
.Create(create => create.Action("DonemKursSinifiOlustur", "Tanim").Data("dataCreate"))
.Update(update => update.Action("DonemKursSinifiGuncelle", "Tanim"))
.Destroy(destroy => destroy.Action("DonemKursSinifiSil", "Tanim"))
.PageSize(20)
.Model(model => model.Id(p => p.Id))
)
.Resizable(resize => resize.Columns(true))
)
// some unnecessary code block
javascript中的onEditSinif函数
function onEditSinif(e) {
var grid = $("#donemGrid").data("kendoGrid");
var rows = grid.select();
if (e.model.isNew()) {
try {
var kontenjan = grid.dataItem(rows).SinifKontenjanSayisi;
var dersAdi = grid.dataItem(rows).DersAdi;
var egitmenAdiSoyadi = grid.dataItem(rows).EgitmenAdiSoyadi;
var donemBaslangicBitis = grid.dataItem(rows).DonemBaslangicBitis;
$("#DonemBaslangicBitis").val(donemBaslangicBitis);
$("#DersAdi").val(dersAdi);
$("#EgitmenAdiSoyadi").val(egitmenAdiSoyadi);
var firstItem = $('#sinifGrid').data().kendoGrid.dataSource.data()[0];
firstItem.set('KontenjanSayisi', kontenjan);
$("#KontenjanSayisi").val(kontenjan);
} catch (f) {
alert("Please select Kurslar first");
// i need to prevent pop up here **
}
}
else {
$('.trhideclass1').hide();
}
}
有没有人知道它是怎么回事?
谢谢