3.2.0

set focus to a cell

How i can set a focus to the cell of the grid?

grid.element[i][j].focus();

That way?

I want that a cell that i specify programmatically gets focus and the editing could start there.

Thank you!

And please somebody reply to the message:)
Charles Roos
May 12,
Hi Charles,

Here's a JavaScript function that is adapted from the code mentioned in the following forum thread: http://www.activewidgets.com/javascript.forum.1394.39/textbox-template-edit-on-double.html

It takes a row index and puts the focus on the first cell of the row for editing. Not sure why it doesn't work unless the last line is done twice. HTH.

function activateEdit(rownum) {

var editor = new Active.HTML.INPUT;
editor.setClass("templates", "input");
editor.setAttribute("type", "text");

editor.setEvent("onblur", function() {

var value = editor.element().value;
template.setItemProperty("text", value);
template.refresh();
template = null;
});

template = obj.getRowTemplate(rownum).getItemTemplate(0);
template.element().innerHTML = editor;

editor.element().focus();
editor.element().focus();
}

D. Cooke
May 13,
When I return focus to a cell sometimes it puts the cursor at the beginning of the cell and sometimes after the last character that was entered in the Text Box... Is there a way to control where the cursor will be placed in the Text Box when focus is returned?? I would prefer to have the cursor positioned at the end of the last character that was entered...
November 10,

This topic is archived.

See also:


Back to support forum