Binding combo on client side and selecting an item

12 posts, 0 answers
  1. khurram
    khurram avatar
    13 posts
    Member since:
    May 2008

    Posted 16 Sep 2008 Link to this post

    Hi,
    In one of a form in our application we have a rad combo which updates itself with data everytime we change some parameters in form. We are using a webservice to get the list of  RadComboItemData and bind on the client side.

    When we bind whats happening is that the last selected text still remains visible even if its not in the new list. We have a required field validator for the list. If I manually do select on the first item (First item displays a message that an item must be selected) of the new list using comboItem.Select() it launches validation and dispalys our required field validator that an item must be selected.
     
    Is there a proper way of doing it so that new list populates itself without any garbage left over from the last binded data?

    My second question is can we do validation on value of the selected item instead of text?

    Thanks in advance for your help.

    Best regards,
    Khurram

    Client side binding function

    function bindCombo(combo,result){     
                
            var items = combo.get_items();  
            items.clear();  
            for(var i=0;i< result.length;i++){  
                var comboItem = new Telerik.Web.UI.RadComboBoxItem();  
                comboItem.set_text(result[i].Text);  
                comboItem.set_value(result[i].Value);  
                items.add(comboItem);  
                if (i == 0) {  
                    comboItem.select();  
                }  
            }        
     

     

  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 17 Sep 2008 Link to this post

    Hello Khurram,

    I suggest you use  combo.set_text(""); right after items.clear(); to clear the selected item.  As to your second question, RadComboBox cannot be validated on value with RequiredFieldValidator, but you can create your custom validator, please check this help topic which shows how to do that. 

    Best wishes,
    Yana
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. khurram
    khurram avatar
    13 posts
    Member since:
    May 2008

    Posted 24 Sep 2008 Link to this post

    Hi,
    We are still having this issue where even if I select values on client side and validation passes; on server side I dont get the newly selected value. Can anyone suggest me what could be causing it?
    Thanks in advance.
    Regards,
    Khurram
  5. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 25 Sep 2008 Link to this post

    Hello Khurram,

    I suggest you use trackChanges() and commitChanges() client-side methods to preserve changes you make after postback like this:

    combo.trackChanges();
    comboItem.select();
    combo.commitChanges();

    Hope this helps.

    Regards,
    Yana
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. khurram
    khurram avatar
    13 posts
    Member since:
    May 2008

    Posted 26 Sep 2008 Link to this post

    Thanks Yana,

    It did work but unfortunately the creation of combo on client side has become really slow. We have a form with combos changing a lot with different actions and we need a really high performance way of doing that. I am using the following code to populate it.

    function bindCombo(combo, result) {  
               combo.trackChanges();  
               var items = combo.get_items();  
               items.clear();             
               for (var i = 0; i < result.length; i++) {  
                   var comboItem = new Telerik.Web.UI.RadComboBoxItem();  
                   comboItem.set_text(result[i].Text);  
                   comboItem.set_value(result[i].Value);  
                   items.add(comboItem);  
                   if (i == 0) {  
                       comboItem.select();  
                   }  
               }  
               combo.commitChanges();  
           }  

    Is there another way of binding that for better performance. We are using a webservice call to get the list of RadComboBoxItemData[] items.

    Thanks in advance for your help.
    Regards,
    Khurram
  7. khurram
    khurram avatar
    13 posts
    Member since:
    May 2008

    Posted 13 Feb 2009 Link to this post

    Any info regarding the slowness of databinding on client side?
    Thanks for your help.
    regards,
    Khurram
  8. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 16 Feb 2009 Link to this post

    Hi Khurram,

    I am not able to understand why you need client-side databinding when you're using a web service to get the items, why don't you bind the combobox directly to the web service?

    Regards,
    Yana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  9. khurram
    khurram avatar
    13 posts
    Member since:
    May 2008

    Posted 16 Feb 2009 Link to this post

    Hi,
    I dont know how this load on demand example can be used in our context as in our case combos are populated based on certain fields changed by a user in a form. For example a user selects different items in a radiobutton list and that will update the items of the combo accordingly. So to avoid a postback on change of radiobuttonlist we call a webservice and bind the new items to our combo on client-side.

    Regards,
    Khurram
  10. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 17 Feb 2009 Link to this post

    Hello Khurram,

    I suggest you use the context object to pass information when you request items.  Please  check this help article for details. Also you're using an old version of the controls, there are some improvements concerning performance in our latest release.

    Kind regards,
    Yana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  11. Anshuman
    Anshuman avatar
    2 posts
    Member since:
    Apr 2013

    Posted 16 May 2014 in reply to Yana Link to this post

    Hi 
    I have bind dropdown ddlColumn with pagemethod(GetColumnList) this is working fine on opening dropdown but after adding a item client side in this dropdown then it is not binding comlete list from page mathod it showing only one item that is added by client code. i want to rebind or want to refresh the list on opening dropdown. 
    HTML:
    <telerik:RadComboBox  ID="ddlColumn" runat="server" Width="250px"
                                        Height="150px" EnableLoadOnDemand="true" ShowMoreResultsBox="true" EnableVirtualScrolling="true"
                                        OnClientSelectedIndexChanged="SelectedIndexChanged" >
    <WebServiceSettings Method="GetColumnList" Path="TestPage.aspx" />
    </telerik:RadComboBox>
     Server:
     [WebMethod(EnableSession = true)]
           public static RadComboBoxData GetColumnList(RadComboBoxContext context)
            {}
    Thanks in advance
    Anshuman

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

    Posted 16 May 2014 in reply to Anshuman Link to this post

    Hi Anshuman,

    Please try the following JavaScript to add a new item to the RadComboBox which works fine at my end.

    JavaScript:
    function AddItem(sender, args) {
        var combo = $find("<%= RadComboBox1.ClientID %>");
        var comboItem = new Telerik.Web.UI.RadComboBoxItem();
        comboItem.set_text("New Item");
        combo.trackChanges();
        combo.get_items().add(comboItem);
        comboItem.select();
        combo.commitChanges();
    }

    Let me know if you have any concern.
    Thanks,
    Shinu.
  13. Anshuman
    Anshuman avatar
    2 posts
    Member since:
    Apr 2013

    Posted 19 May 2014 in reply to Shinu Link to this post

    Hi Shinu
    Thanks for your response, i have code in same fashion, if it is working at your end then might be some issue in my dll version of code, now i have code in another way

    Thanks again

    Anshuman  
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017