RadComboBox from js

16 posts, 0 answers
  1. Zÿm
    Zÿm avatar
    26 posts
    Member since:
    Jun 2010

    Posted 23 Dec 2011 Link to this post

    hi,
     I am doing some testing. I need to change radComboBox selected value from javascript. How can i achieve that? But it is rendered to list...what is necessary to set ? ClientState is not enough...
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 26 Dec 2011 Link to this post

    Hello,

    Try the following.
    JS:
    <script type="text/javascript">
    function OnClientSelectedIndexChanged(sender, args)
      {
        var text = sender.get_selectedItem().get_text();
        sender.set_text(text);
         sender.set_value(text);
      }
    </script>

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Zÿm
    Zÿm avatar
    26 posts
    Member since:
    Jun 2010

    Posted 26 Dec 2011 Link to this post

    Eghm....it is more complicated...I want to change already rendered radCombobox value. I have no problem with other inputs such as select, input...As i said i am doing some web ui testing. Thanks.
  5. Zÿm
    Zÿm avatar
    26 posts
    Member since:
    Jun 2010

    Posted 27 Dec 2011 Link to this post

    If i add to css "li.rcbHovered" and in input write text, would this save radComboBox value?
  6. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 27 Dec 2011 Link to this post

    Hi,

    Could you clarify a little bit more what exactly is your scenario?

    To learn how to use the client-side API of the RadComboBox, you could refer to the following documentation section: RadComboBox / Client-side Programming.

    Kind regards,
    Ivana
    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
  7. Zÿm
    Zÿm avatar
    26 posts
    Member since:
    Jun 2010

    Posted 27 Dec 2011 Link to this post

       I don't know, how to explain it...I know about client-side of RadComboBox. But i need to set value already on published website through javascript.
      To make it simpler here is a simple example: if i want to change textbox value i just write with js:

    var txt = document.getElementById('ct00_window_txtName');
    txt.value = 'new value';

    So how to change value of radComboBox? Because it is rendered not to select input, but to the list.
  8. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 28 Dec 2011 Link to this post

    Hello,

    Try the following:
    var combo = $find('<%= RadComboBox1.ClientID%>')
    //Find item by its text.
    var item = combo.findItemByText("item1");
    if(item){
      //When setting an item as selected will automatically show its text in the RadComboBox's input area.
      item.select();
       
      //To set text in the input area, you can also use the following:
      combo.set_text(item.get_text());
    }
    //Or find item by its value.
    combo.findItemByValue("item1_value").select();

    I hope this helps.

    Kind regards,
    Ivana
    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
  9. Zÿm
    Zÿm avatar
    26 posts
    Member since:
    Jun 2010

    Posted 28 Dec 2011 Link to this post

    How is this helpful? You basically posted the same answer as before. Have you even read these posts? I don't know how to make my self clearer. I thought i could find answer more faster here I guess i will need to find on my own.
     
    Ok, maybe then you can answer this, here is a rendered RadComboBox, and there is a ctl00_window_Form_Organization_ClientState input, for what it is used?

    <div id="ctl00_window_Form_Organization">
    <table summary="combobox">
    <tr class="rcbReadOnly">
    <td>
    <input name="ctl00$window$Form$Organization" type="text" id="ctl00_window_Form_Organization_Input" value="value 1" readonly="readonly" />
    </td>
    <td>
    <a id="ctl00_windowContent_Form_Organization_Arrow">select</a>
    </td>
    </tr>
    </table>
    <!-- 2011.3.1115.40 -->
    <div>
    <div id="ctl00_window_Form_Organization_DropDown">
    <div>
    <ul>
    <li class="rcbItem ">value 1</li>
    <li class="rcbItem ">value 2</li>
    <li class="rcbItem ">value 3</li>
    <li class="rcbItem ">value 4</li>
    <li class="rcbItem ">value 5</li>
    <li class="rcbItem ">value 6</li>
    </ul>
    </div>
    </div>
    </div>
    <input id="ctl00_window_Form_Organization_ClientState" name="ctl00_window_Form_Organization_ClientState" type="hidden" />
    </div>

    Hope is for sissies.
    Kind regards 

  10. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 28 Dec 2011 Link to this post

    Hi,

    The input with ID="ctl00_window_Form_Organization_ClientState" is a hidden field, and it it used to transfer data from client to server and vice versa. The purpose of this input is to transfer data only -- its logic is implemented in the RadComboBox control, and should not be accessed or altered by the users.

    As in the code provided in your previous post, the RadComboBox is rendered with the following ClientID:
    ctl00_window_Form_Organization. Now, you can use this ID to get the RadComboBox client object:
    $find("ctl00_window_Form_Organization");
    Having the client object of RadComboBox, you could change its value and text, using the client API of the control.
    //Change the value of the RadComboBox object itself.
    $find("ctl00_window_Form_Organization").set_value("my value");
    //Change the value of the RadComboBox object by selecting an item.
    $find("ctl00_window_Form_Organization").get_items().getItem(0).select();

    To alter the value of the input DOM element of RadComboBox input area, you could do the following:
    $get("ctl00_window_Form_Organization_Input").value = "my value";
    $get is a AJAX representation of the document.getElementById JavaScript method.

    If you are still having troubles, in order to help you, we will need more information about the scenario you are trying to achieve. If the issues you are experiencing are still not resolved, you could send us a support ticket on this matter, where a sample page could be attached.

    Kind regards,
    Ivana
    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
  11. Zÿm
    Zÿm avatar
    26 posts
    Member since:
    Jun 2010

    Posted 02 Jan 2012 Link to this post

    Ok thanks for your time. This still does not answer the question. I don't really understand, is this very hard question, that you misunderstanding it. I found other way how to change it, but thanks anyway :). By the way i had problem not only with RadCombobox, but with RadDate... pickers.
  12. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 03 Jan 2012 Link to this post

    Hello,

    I am glad you were able to resolve your scenario.  Could you share the solution,  so that the whole forum community could benefit from it?

    Greetings,
    Ivana
    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
  13. Zÿm
    Zÿm avatar
    26 posts
    Member since:
    Jun 2010

    Posted 03 Jan 2012 Link to this post


    1. I am finding arrow anchor by its id.
    2. initiate click 
    3. finding li element by text (or link=day_number if calendar)
    4. initiate click

    but is very inconvenient. I am wondering how to save value to "_ClientState elements". Is this good Ivana? have i shared the answer?
  14. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 05 Jan 2012 Link to this post

    Hello,

    Yes, this is a right approach when working directly with html elements:

    1. Click on RadCombobBox arrow - represented by A with id = ComboID_Arrow.
    2. Wait for RadComboBox items to appear.
    3. Click on particular RadComboBox item - represented by LI element.


    As for the input with ID: [RadComboBox_ID]_ClientState, the value could be accessed using the element's attribute: value, as in the following example:
    $get([RadComboBox_ID] + "_ClientState").value = "my value"; 

    Kind regards,
    Ivana
    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
  15. Alberto
    Alberto avatar
    2 posts
    Member since:
    Jul 2012

    Posted 19 Aug 2015 in reply to Ivana Link to this post

    Hi Ivana, I know the post is old, but how do you click on the Li Items?  I can get the LI Items in a link, and click on the Arrow.
  16. Alberto
    Alberto avatar
    2 posts
    Member since:
    Jul 2012

    Posted 19 Aug 2015 in reply to Zÿm Link to this post

    Hi Zym, I have a similar issue, how did you find the Li Items?  and then clicked on them?  I'm stuck with javascript.
  17. Eyup
    Admin
    Eyup avatar
    3005 posts

    Posted 24 Aug 2015 Link to this post

    Hello Alberto,

    Could you elaborate on what exactly you want to achieve? You can also send us sample screenshots or video demonstrating the required behavior. Thus, we will be able to figure out your specific scenario and prepare a sample web site to send it to you.

    Regards,
    Eyup
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017