實作修改操作是教職工号不可編輯,添加時教職工号可編輯功能
通過設定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);
}
}
}
效果