You can specify the column editor before editing a row. Please try the code below:
$('#dg').datagrid({
onBeforeEdit: function(index,row){
var col = $(this).datagrid('getColumnOption', 'itemid');
if (some condition){
col.editor = 'text';
} else {
col.editor = null;
}
}
})