Hi,
In my grid i have <telerik:GridNumericColumn..../> columns.When grid goes into edit mode i add onFocus evenet handlers
GVDataGridNumericColumn gc = this.Columns[ColumnCounterIndex] as GVDataGridNumericColumn;
RadNumericTextBox radNumericTextBox = control as RadNumericTextBox;
//add event handler
radNumericTextBox.TextChanged += new EventHandler(RadGridRadNumericTextBox_TextChanged);
//add js event handler
radNumericTextBox.Attributes.Add("OnFocusIn", "StoreMe( radNumericTextBox.ClientID)");
In StoreMe stores ClientID in hidden field and in PageLoad
function pageLoad(sender, args)
{
$find(ClientID).focus();
}
this suppose to set focus in RadNumericTextBox, but somehow it doesn't.
alert($find(ClientID)); returns [object Object].
Please let me know where is the bug/mistake in code.
thanks
virendra
5 Answers, 1 is accepted
0

Princy
Top achievements
Rank 2
answered on 18 Sep 2009, 01:03 PM
Hello Virendra,
I suppose you are trying to set focus to the RadNumericTextBox when the grid is in editmode. If thats the case, try out the following code:
aspx:
c#:
Thanks
Princy.
I suppose you are trying to set focus to the RadNumericTextBox when the grid is in editmode. If thats the case, try out the following code:
aspx:
<telerik:GridNumericColumn DataField="Number" HeaderText="NumericColumn" UniqueName="NumericColumn"> |
</telerik:GridNumericColumn> |
c#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) |
{ |
if (e.Item is GridEditableItem && e.Item.IsInEditMode) |
{ |
GridEditableItem editableItem = (GridEditableItem)e.Item; |
RadNumericTextBox numrctxtbx = (RadNumericTextBox)editableItem["NumericColumn"].Controls[0]; |
numrctxtbx.Focus(); |
} |
} |
Thanks
Princy.
0

Virendra
Top achievements
Rank 1
answered on 22 Sep 2009, 04:13 AM
Hi Princy,
I am trying to set focus in client-side, Javascript.
The server-side focus setting works for NumericColumn but not for other column-types like TextBox, Checkbox.
thanks
virendra
0

Mike
Top achievements
Rank 1
answered on 22 Sep 2011, 08:43 PM
Did you ever figure out an answer to this? I am currently experiencing the same problem. Calling focus() on cells in GridBoundColumn works fine. Calling focus() on cells in GridNumericColumn doesn't.
Jamie
Jamie
0
Hello Jamie,
You should access the text element of the RadNumericTextBox control in order to focus it:
javascript:
I hope this helps.
Greetings,
Tsvetina
the Telerik team
You should access the text element of the RadNumericTextBox control in order to focus it:
protected
void
RadGrid1_ItemCreated(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridEditableItem && e.Item.IsInEditMode)
{
((e.Item
as
GridEditableItem)[
"OrderID"
].Controls[0]
as
RadNumericTextBox).ClientEvents.OnLoad =
"load"
;
}
}
javascript:
function
load(sender, eventArgs) {
$get(sender.get_id() +
'_text'
).focus();
}
I hope this helps.
Greetings,
Tsvetina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0

Mike
Top achievements
Rank 1
answered on 27 Sep 2011, 07:57 PM
Thanks, that looks promising. However, I did finally figure out a solution.
Here is my "moveDown" method. The variable gridIds is a two dimensional array that has the cell IDs by Y and X. If $find(newCell.id) doesn't return null, then it's a numeric textbox. The onfocus handler sets selectedId, selectedX, and selectedY.
Perhaps I'll revisit this and see if your solution seems safer.
Thanks,
Jamie
Here is my "moveDown" method. The variable gridIds is a two dimensional array that has the cell IDs by Y and X. If $find(newCell.id) doesn't return null, then it's a numeric textbox. The onfocus handler sets selectedId, selectedX, and selectedY.
if
(selectedId !=
null
) {
if
(selectedY < visibleItemCount - 1) {
var
newCellId = gridIds[selectedY + 1][selectedX];
var
newCell = $get(newCellId);
var
numericCtl = $find(newCell.id);
if
(numericCtl !=
null
) {
numericCtl.focus();
}
else
{
newCell.focus();
}
}
}
Perhaps I'll revisit this and see if your solution seems safer.
Thanks,
Jamie