1

我有一个 Dojo Datagrid,其中一列由格式化程序函数呈现为文本框。当我单击呈现的文本框输入一些值时,光标出现在文本框中并且焦点立即丢失(即,光标消失 - 键入不会产生任何内容)。我必须再次单击文本框以设置焦点 - 只有这样我才能输入值。

有没有办法将焦点设置在第一次点击本身上?

这是代码:

<table dojoType="dojox.grid.DataGrid" store="selectedItemsStore" class="resultsGridClass" jsid="selecteditems">
<thead>
<tr>
<th field="field1" formatter="renderTextBox" width="20%">Field 1</th>
</tr>
</thead>
</table>

这是格式化程序功能:

function renderTextBox(value, rowIndex) {
var htmlString = "<input type='text' name= 'exp' />";
return htmlString;
}
4

4 回答 4

1
window.setTimeout(function() {
    dijit.byId("profileGrid").scrollToRow(rowIndex);
    dijit.byId("profileGrid").focus.setFocusIndex( rowIndex, 0 );
    dijit.byId("profileGrid").edit.setEditCell( dijit.byId("profileGrid").getCell(0), rowIndex );
},10);
于 2012-09-13T20:03:10.580 回答
0

尝试将 editable 和 alwaysEditing 属性设置为 true:

<th alwaysEditing="true" editable="true" field="field1" formatter="renderTextBox" width="20%" >Field 1</th>
于 2009-10-16T09:59:13.600 回答
0

在创建 的实例时dojox.grid.EnhancedGrid,使用singleClickEdit属性并将其设置为true

这将在第一次单击时将焦点设置在文本框或任何其他小部件上。

于 2012-06-15T12:38:38.533 回答
0

在我的例子中,下面的代码非常适合文本框焦点问题:

dojo.connect(this.floorTable,"onRowClick",this,function(row){               
    row.target.focus();             
});

this.floorTable表对象在哪里。

于 2017-07-06T12:26:41.780 回答