用easyUi editGrid 发现 设置 单机后 获得焦点无效(个人觉得巨坑,明明照着 easyui 官网撸的怎么就不能获的焦点了呢!!)
javascript 如下:
function onClickCell(index,field){
IsCheckFlag=false;
if (editIndex != index){
if (endEditing()){
$('#dg').datagrid('beginEdit', index);
editIndex = index;
focusEditor(field);//获得焦点
} else {
//$('#dg').datagrid('selectRow', editIndex);
}
}else{
//单机同一行 选择不同 列
focusEditor(field);
}
}
//单击行的时候 取消选中效果
var IsCheckFlag=true;
function onSelect (rowIndex, rowData) {
if (!IsCheckFlag) {
IsCheckFlag = true;
$("#dg").datagrid("unselectRow", rowIndex);
}
}
function focusEditor(field){
console.log(field);
var editor = $('#dg').datagrid('getEditor', {index:editIndex,field:field});
if (editor){
editor.target.focus();
$(editor.target).focus();
$(editor.target).focus().bind('blur', function () {
alert("什么时候取消了 事件????");
});
} else {
var editors = $('#dg').datagrid('getEditors',editIndex);
if (editors.length){
editors[0].target.focus();
}
}
}
grid 如下:
<table id="dg" class="easyui-datagrid" title="<h>收件材料</h>" style="width:100%;height:auto;"
data-options="
singleSelect: false,
striped:true,
fit : true,
rownumbers : true,
toolbar: '#tb',
url: '******',
method: 'get',
onClickCell:onClickCell,
onSelect:onSelect
">
<thead>
<tr>
<th data-options="field:'ID',width:80,hidden:true">id</th>
<th data-options="field:'ck',checkbox:true"></th>
<th data-options="field:'ORDERINDEX',sortable:'true',width:80,align:'center',editor:{type:'numberbox',options:{}},hidden:true">顺序</th>
<th data-options="field:'NAME',width:367,align:'center',editor:{type:'textbox',options:{}}">收件名称</th>
<th data-options="field:'TYPE',width:190,
formatter: function(v, r, i) {
return type[v];
},
editor:{
type:'combobox',
options:{
valueField:'value',
textField:'text',
method:'get',
data:types,
}
}">收件类型</th>
<th data-options="field:'COPYNUM',width:80,align:'center',editor:{type:'numberbox',options:{}}">份数</th>
<th data-options="field:'PAGENUM',width:80,align:'center',editor:{type:'numberbox',options:{}}">页数</th>
<th data-options="field:'SCANNUM',width:80,align:'center',editor:{type:'numberbox',options:{}}">扫描数</th>
<th data-options="field:'PAGERANGE',width:80,align:'center'">页次</th>
<th data-options="field:'BZ',width:300,align:'center',editor:'textbox'">备注信息</th>
</tr>
</thead>
</table>
包含括js 调试 esitor.targer 显示为: input元素, 到这里我疯了。。。 就为了个获得焦点事件
最后了个例子, 发现
官网的例子 type 为 “text”,然后 我将 type 换成 “text” 发现可行。
最后 才发现 easyui de “textbox” 和 ”numberbox “
不能正常的获取 焦点,最后 通过观察 页面元素,将 获取焦点事件改为:
获取焦点 没问题了。(后续版本的 easyui 可能支持 textbox 点击事件)