…………
@(Html.DevExtreme().DataGrid<Model>()
…………
.ID("gridMetting")
.Mode(GridEditMode.Popup)
.Popup(p => p
.Title("会议报备")
.ShowTitle(true)
.Width("auto").MaxWidth("80%")
.Height("auto").MaxHeight("98%")
.Position(pos => pos
.My(HorizontalAlignment.Center, VerticalAlignment.Center)
.At(HorizontalAlignment.Center, VerticalAlignment.Center)
.Of("#gridMetting")
)
.DragEnabled(true)
)
.Form(f =>
f.Items(item =>{
item.AddSimpleFor(n => n.Name).ValidationRules(r => r.AddRequired().Message("不能为空"));
item.AddSimpleFor(n => n.Remark).Editor(e => e.TextArea().Height(100));
})
)
.OnEditorPreparing("onEditorPreparing")
.OnEditingStart("onEditingStart")
.OnInitNewRow("onInitNewRow")
…………
)
<script>
var isEdite;
//初始化页面控件
function onEditorPreparing(e) {
if (isEdite) {
if (e.parentType === "dataRow") {
//修改时,设置指定文本框不可更改
if ( e.dataField === "Remark") {
e.editorOptions.disabled = true;
}
}
}
}
//修改事件
function onEditingStart(e) {
isEdite = true;
}
//添加事件
function onInitNewRow(e) {
isEdite = false;
}
</script>