動態改變列的編輯屬性css
var tt=$('#dg').datagrid('getColumnOption', 'yearContent'); //經過列名得到此列 tt.editor={type:'textarea'}; //設置此列的編輯屬性 若是禁用編輯 則設置 tt.editor={}
新增一行時 yearContent 列能夠編輯app
function append(){ if (endEditing()){ $('#dg').datagrid('appendRow',{});//新增一行 var tt=$('#dg').datagrid('getColumnOption', 'yearContent'); tt.editor={type:'textarea'}; editIndex = $('#dg').datagrid('getRows').length-1; $('#dg').datagrid('selectRow', editIndex) .datagrid('beginEdit', editIndex); $("textarea").css("height","85px"); } }
點擊一行時 yearContent 列不能夠編輯spa
function onClickRow(index,field,value){ if (editIndex != index){ if (endEditing()){ var tt=$('#dg').datagrid('getColumnOption', 'yearContent'); tt.editor={}; $('#dg').datagrid('selectRow', index) .datagrid('beginEdit', index); editIndex = index; } else { $('#dg').datagrid('selectRow', editIndex); } $("textarea").css("height","85px"); } }