Datagrid扩展方法onClickCell{easyui-datagrid-扩充-支持单元格编辑}

//-----------------------------------------------------------------
/*************************************************************
*@调用方法:{onClickCell:MCBaseDBGrid.DefaultCell}
*@功能: Datagrid扩展方法onClickCell{easyui-datagrid-扩充-支持单元格编辑}
*@date: 2016-10-25
*@user; hwm
**************************************************************/
MCBaseDBGrid.DefaultCell = function (index, field, value) {
MCBaseDBGrid.CustomClickCell(this, index, field, value);
}
//-----------------------------------------------------------------
/*************************************************************
*@调用方法:《 onClickCell:function (this index, field, value){MCBaseDBGrid.CustomClickCell(this,index, field, value)} 》
*@功能: Datagrid扩展方法onClickCell{easyui-datagrid-扩充-支持单元格编辑}
*@date: 2016-10-25
*@user; hwm
**************************************************************/
MCBaseDBGrid.CustomClickCell = function (_this, index, field, value) {
var isfind = false;
if (MCBaseDBGrid.editIndex != -1) {
$(_this).datagrid('endEdit', MCBaseDBGrid.editIndex);
}
var fields = $(_this).datagrid('getColumnFields', true).concat($(_this).datagrid('getColumnFields'));
for (var i = 0; i < fields.length; i++) {
var col = $(_this).datagrid('getColumnOption', fields[i]);
col._editor_bak = col.editor;
if (fields[i] == field && (col.editor != undefined)) {
isfind = true;
}
if (fields[i] != field) {
col.editor = undefined;
}
}
if (isfind == false) {
$(_this).datagrid('endEdit', MCBaseDBGrid.editIndex);
}
else {
$(_this).datagrid('beginEdit', index);
MCBaseDBGrid.editIndex = index;
var ed = $(_this).datagrid('getEditor', { index: index, field: field });//获取编辑属性
if (ed) {
if ($(ed.target).hasClass('textbox-f')) {
$(ed.target).textbox('textbox').focus();
$(ed.target).textbox('textbox').select();
} else if ($(ed.target).hasClass('combogrid-editable-input')) {
$(ed.target).parent().find(".combo-text").focus();
$(ed.target).parent().find(".combo-text").select();
} else {
$(ed.target).focus();
$(ed.target).select();
}
}
}

for (var i = 0; i < fields.length; i++) {
var col = $(_this).datagrid('getColumnOption', fields[i]);
col.editor = col._editor_bak;
}
}

上一篇:使用邮件激活授权/ LightningChart license


下一篇:HDU 1114 完全背包+判断能否装满