views:

620

answers:

1

I have a Dojo Datagrid with one of the columns being rendered as a textbox by a formatter function. When I click on the rendered textbox to enter some value, the cursor appears in the textbox and focus is immediately lost (i.e, the cursor disappears - typing does not produce anything). I have to click once more on the textbox for the focus to set - only then can I enter values.

Is there any way to set the focus on the first click itself?

Here is the code:

<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>

And here is the formatter function:

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

Try setting editable and alwaysEditing attributes to true:

<th alwaysEditing="true" editable="true" field="field1" formatter="renderTextBox" width="20%" >Field 1</th>
ivalkeen
Nope. Does not work.
Shivasubramanian A
You can try to repeat behavior from this test page (when Toggle dSingleClickEdit is pressed): http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/grid/tests/test_edit.html
ivalkeen