Issue Setting Focus RadDatePicker

2 posts, 0 answers
  1. Robert
    Robert avatar
    199 posts
    Member since:
    Aug 2009

    Posted 16 Sep 2011 Link to this post

    I am having an issue setting focus on the text box of a RadDatePicker.  I handle the 

    OnDateSelected 

     

     

    event and then set focus using:

    e.get_textBox().focus();
    e.get_textBox().select();

    however this only works when there is no date in the textbox.  If I choose another date focus may be at that object but the cursor is not visible.  Currently I have a workaround to handle this but it is not elegant:

    function

     

     

    OnDatePopupClosing(e, args) {

     

     

     

     

     

    try

    {

     

    SelectedDate = e.get_selectedDate();

     

     

     

     

    if (SelectedDate) {

     

     

     

    e.get_textBox().value =

     

    ''

    ;

     

    }

    }

     

    catch (err) {

     

     

     

    alert(

     

    "Error encountered: " + err.message)

     

    }

    }

    function

     

     

    OnDateSelected(e, args) {

     

     

     

     

     

    try

    {

     

     

     

    if (e.CalendarSelectionInProgress) {

     

     

     

    e.get_textBox().select();

    }

    }

     

     

     

    catch (err) {

     

     

     

    alert(

     

    "Error encountered: " + err.message)

     

    }

    }

     
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 26 Sep 2011 Link to this post

    Hello Robert,

    You could achieve the desired behavior from client side.For that you need to
    • Get the client-side instance of the combobox
    • Get the DOM element of the input field
    • Focus the input field

    Please check this help article which which explains more on this.

    Thanks,
    Shinu.
Back to Top