Clear focus on edited item when prepopulated

2 posts, 1 answers
  1. Richard Weeks
    Richard Weeks avatar
    95 posts
    Member since:
    Oct 2009

    Posted 08 Aug 2011 Link to this post

    I have a grid that, upon new or edited record displays GridNumericColumns with partially prepopulated values (e.g. 1234).

    When clicking the cell, the prepopulated value is highlighted. Any typing will clear the prepopulated value. I don't want that.

    Ideally, I'd like the cursor to position after the partially prepopulated value when the user clicks the cell, so they can complete the value (e.g. 12345678).

    Any ideas?

  2. Answer
    Tsvetina avatar
    1860 posts

    Posted 12 Aug 2011 Link to this post

    Hi Richard,

    For this purpose you can set the SelectionOnFocus property of the numeric textbox to CaretToEnd, as shown below:
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
        if (e.Item is GridEditableItem && e.Item.IsInEditMode)
            GridEditableItem item = e.Item as GridEditableItem;
            (item["ColumnUniqueName"].Controls[0] as RadNumericTextBox).SelectionOnFocus = SelectionOnFocus.CaretToEnd;

    I hope this helps.

    Best wishes,
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. DevCraft R3 2016 release webinar banner
Back to Top