动态设置easyui数据表格编辑状态
实现修改操作是教职工号不可编辑,添加时教职工号可编辑功能
通过设置
var tt=$('#teachertb').datagrid('getColumnOption', 'tid');//得到此列
tt.editor={};//设置此列不可编辑
新添一行
function appendtea(){//添加
if (teaendEditing()){
$('#teachertb').datagrid('appendRow'
,{});
var tt=$('#teachertb').datagrid('getColumnOption','tid');// 得到此列,tid指的是列的field
tt.editor={type:'validatebox', options: { required: true}};//设置此列可编辑
teaeditIndex=$('#teachertb').datagrid('getRows').length-1;
$('#teachertb').datagrid('selectRow', teaeditIndex)
.datagrid('beginEdit', teaeditIndex);
}
}
修改
function teaonClickRow(index){
if (teaeditIndex != index){
if (teaendEditing()){
var tt=$('#teachertb').datagrid('getColumnOption', 'tid');//得到此列
tt.editor={};//设置此列不可编辑
$('#teachertb').datagrid('selectRow', index)
.datagrid('beginEdit', index);
teaeditIndex = index;
} else {
$('#teachertb').datagrid('selectRow', teaeditIndex);
}
}
}
效果

评论已关闭