Get RadComboBox check values as string

3 posts, 0 answers
  1. Max
    Max avatar
    18 posts
    Member since:
    Apr 2016

    Posted 05 May Link to this post

    I have a RadComboBox with checkboxes and I want to get all the values in the DataValueField as a comma separated string.

    $get("myComboBox").value gets me a comma separated string of the DataTextField and not the DataValueField.

    How do I do this?

  2. Max
    Max avatar
    18 posts
    Member since:
    Apr 2016

    Posted 05 May in reply to Max Link to this post

    I mean to ask how I do it client-side
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ivan Zhekov
    Admin
    Ivan Zhekov avatar
    540 posts

    Posted 06 May Link to this post

    Hi, Max.

    It's actually really simple: you just loop over the checked indices, then push the values inside an array and finally join the array e.g.:

    function getValuesGeneric( combobox ) {
     
        var values = [];
        var items = combobox.get_items();
     
        Array.forEach( combobox.get_checkedIndices(), function( element, index ) {
            var item = items.getItem( element );
            values.push( item.get_value() );
        });
     
        alert( values.join(",") );
    }

    Where as combobox is the client-side object.

    I've also attached a simple page with the code.


    Regards,
    Ivan Zhekov
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top