@(Html.Kendo().Grid<CRMVehicleViewModel>()
.Name("CompanyGrid")
.Columns(columns =>
{
columns.Bound(p => p.VehicleId).Hidden(true);
columns.Bound(p => p.RegNo);
columns.ForeignKey(p => p.FranchiseCode, (System.Collections.IEnumerable)ViewData["FranchiseCode"], "Value", "Text").EditorTemplateName("GridForeignKey").Title("Franchise Code").Width(150);
columns.ForeignKey(p => p.Model, (System.Collections.IEnumerable)ViewData["ModelCode"], "Value", "Text").EditorTemplateName("GridForeignKey").Title("Model Code").Width(150);
columns.ForeignKey(p => p.Variant, (System.Collections.IEnumerable)ViewData["VariantCode"], "Value", "Text").EditorTemplateName("GridForeignKey").Title("Variant Code").Width(150);
columns.Bound(p => p.EngNo);
columns.Bound(p => p.chessisno);
columns.Bound(p => p.Description);
columns.Command(command => { command.Destroy().Text(" ");command.Create().Text(" ") }).Title("Action").Width(100);
})
.ToolBar(toolbar =>
{
{ toolbar.Create(); }
})
.Editable(editable => editable.Mode(GridEditMode.PopUp))
.Pageable(p => p.Numeric(false).PreviousNext(false))
.Sortable()
.Scrollable(sc => sc.Endless(true))
.HtmlAttributes(new { style = "height:90%;" })
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(false)
.PageSize(20)
.Model(model => model.Id(p => p.VehicleId))
.Read(read => read.Action("GetVehicles", "CRM"))
.Create(create => create.Action("AddVehicles", "CRM"))
.Destroy(update => update.Action("DeleteVehicles", "CRM"))
).Events(e => e.Edit("onEdit")))
<script>
function onEdit(e) {
var _txt1 = e.container.find("input:EngNo").val();
var _txt2 = e.container.find("input:chessisno").val();
if (_txt1 == _txt2) {
alert('Matching!');
return true;
}
else {
alert('Not matching!');
return false;
}
}
</script>
我想保留文本框'EngNo'和文本框'ChessisNo',在从弹出窗口插入之前,两个字段必须不同,我已经添加了脚本,但是它不起作用,请帮我解决此问题。
答案 0 :(得分:0)
<script>
function onEdit(e) {
var _txt1 = e.container.find("input[name='EngNo']").val() ;
var _txt2 = e.container.find("input[name='chessisno']").val();
if (_txt1 == _txt2) {
alert('Matching!');
return true;
}
else {
alert('Not matching!');
return false;
}
}
</script>