Radcombobox getting access to value from server

5 posts, 1 answers
  1. Maxim
    Maxim avatar
    4 posts
    Member since:
    Jun 2014

    Posted 26 Jun 2014 Link to this post

    Hi, im trying to get access to the value from the data that is feed by a webservice. The data is displayed well, but I want that when the page load, the first item must be selected in some case, so I need to feed the selected value for this, but I don't have it. So my problem is that I can't access the radcombobox.items from anywhere.

    01.<telerik:RadScriptBlock runat="server">
    02.  <script type="text/javascript">
    03.    function onClientSelectedIndexChangingAddress(sender, eventArgs)
    04.    {
    05.      if (!eventArgs.get_item() || eventArgs.get_item().get_value() == "")
    06.      {
    07.        eventArgs.set_cancel(true);
    08.      }
    09.    }
    10. 
    11.    function onClientSelectedIndexChangedAddress(sender, eventArgs)
    12.    {
    13.      var idTxtLastSelectedItem = sender.get_id();
    14.      idTxtLastSelectedItem = idTxtLastSelectedItem.substring(0, idTxtLastSelectedItem.indexOf("oucAddressDropDownExtended") + 26) + "_txtLastSelectedItem";
    15.      document.getElementById(idTxtLastSelectedItem).value = sender.get_text();
    16.      sender.clearItems();
    17.    }
    18. 
    19.    function onClientItemsRequestingAddress(sender, eventArgs) {
    20.      var idTxtLastSelectedItem = sender.get_id();
    21.      idTxtLastSelectedItem = idTxtLastSelectedItem.substring(0, idTxtLastSelectedItem.indexOf("oucAddressDropDownExtended") + 26) + "_txtLastSelectedItem";
    22. 
    23.      var txtUserGroupID = document.getElementById("<%= txtUserGroupID.ClientID %>");
    24.      var txtUserID = document.getElementById("<%= txtUserID.ClientID %>");
    25.      var txtTermChooseAnAddress = document.getElementById("<%= txtTermChooseAnAddress.ClientID %>");
    26.      var txtTermAddressNoMatch = document.getElementById("<%= txtTermAddressNoMatch.ClientID %>");
    27.      var txtTermAddressResults = document.getElementById("<%= txtTermAddressResults.ClientID %>");
    28.      var txtHidePartnerPrincipalAddress = document.getElementById("<%= txtHidePartnerPrincipalAddress.ClientID %>");
    29. 
    30. 
    31.      var lastItemRequested = document.getElementById(idTxtLastSelectedItem).value;
    32.      if (lastItemRequested == sender.get_text()) {
    33.        eventArgs._context.Text = "";
    34.      }
    35. 
    36.      if (txtUserGroupID.value != "") {
    37.        eventArgs.get_context()["UserGroupID"] = txtUserGroupID.value;
    38.      }
    39. 
    40.      if (txtUserID.value != "") {
    41.        eventArgs.get_context()["UserID"] = txtUserID.value;
    42.      }
    43. 
    44.      eventArgs.get_context()["TermChooseAnAddress"] = txtTermChooseAnAddress.value;
    45.      eventArgs.get_context()["TermAddressNoMatch"] = txtTermAddressNoMatch.value;
    46.      eventArgs.get_context()["TermAddressResults"] = txtTermAddressResults.value;
    47.      eventArgs.get_context()["HidePartnerPrincipalAddress"] = txtHidePartnerPrincipalAddress.value;
    48.    }
    49.    
    50.  </script>
    51.</telerik:RadScriptBlock>



    1.<telerik:RadComboBox ID="lstShippingAddress" runat="server" EnableEmbeddedSkins="false" Skin="eCom" MaxHeight="250px" EnableLoadOnDemand="True" EnableVirtualScrolling="True" ShowMoreResultsBox="True" AllowCustomText="true" DropDownWidth="500px" OnClientItemsRequesting="onClientItemsRequestingAddress" OnClientSelectedIndexChanging="onClientSelectedIndexChangingAddress" OnClientSelectedIndexChanged="onClientSelectedIndexChangedAddress" >
    2.  <WebServiceSettings Method="GetAddresses" Path="/EcomUtilsWS.asmx" />
    3.</telerik:RadComboBox>
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 27 Jun 2014 in reply to Maxim Link to this post

    Hi Maxim,

    When Load-On-Demand is using RadComboBox doesn't loads the items initially. In order to achieve your scenario you have to set the Text in Page_Load event to have this as selected Item in RadComboBox.  Please take a look into this forum thread which discuss about the same scenario.

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Maxim
    Maxim avatar
    4 posts
    Member since:
    Jun 2014

    Posted 27 Jun 2014 in reply to Princy Link to this post

    And what if I don't know what text write ? I won't be able to select the item and that's precisely my problem, because if I know the value I can do as you say and set the text, but I don't know what is the first selected item in the radcombobox is (the value is not set from 0 to n, but are the id of address, so I got no choice but to try to fetch the items or find an other way to set the selectedvalue to the first item in the radcombobox. I don't think it's possible with our current way of doing, but the problem is that I can't change it.

    Here is how the RadComboBoxItemData are set on the webservice :

    1.Dim itemData As New RadComboBoxItemData()
    2.        itemData.Text = EcommerceFunctions.GetAddressDescriptionDropdown(oAddresses.Item(i), oPartner)
    3.        itemData.Value = oAddresses.Item(i).Id.ToString
    4.        lstResult.Add(itemData)

    Thanks !
  5. Maxim
    Maxim avatar
    4 posts
    Member since:
    Jun 2014

    Posted 27 Jun 2014 in reply to Maxim Link to this post

    I also need to get the value of the first item selected, because I need it for further use, so what Im trying to do is :

    myRadComboBox.selectedItem = 0  ' set the first when page load

    myValue = myRadComboBox.SelectedValue ' get the value of the first selected item that I set.

    or

    oAdress = GetFirstAdress() ' retrieve the first item from the radCombobox






  6. Maxim
    Maxim avatar
    4 posts
    Member since:
    Jun 2014

    Posted 27 Jun 2014 in reply to Maxim Link to this post

    In the end I called the webservice manually from odebehind and returned the data that I needed from it :

    01.Dim oRadComboBoxContext As New RadComboBoxContext
    02.Dim oEcomUtilsWS As New EcomUtilsWS
    03.Dim oRadComboBoxData As RadComboBoxData
    04.Dim oRadComboBoxItems As New List(Of RadComboBoxItemData)
    05.Try
    06.  oRadComboBoxContext.Add("UserID", oUserId)
    07.  oRadComboBoxContext.Add("TermChooseAnAddress", String.Empty)
    08.  oRadComboBoxContext.Add("termNoAddress", String.Empty)
    09.  oRadComboBoxContext.Add("termNoSelection", String.Empty)
    10.  oRadComboBoxContext.Add("lstAddressResults", String.Empty)
    11.  oRadComboBoxContext.Add("lstAddressNoMatch", String.Empty)
    12.  oRadComboBoxContext.Add("TermAddressResults", String.Empty)
    13.  oRadComboBoxContext.Add("TermAddressNoMatch", String.Empty)
    14.  oRadComboBoxContext.Text = String.Empty
    15.  oRadComboBoxContext.NumberOfItems = 0
    16. 
    17.  oRadComboBoxData = oEcomUtilsWS.GetAddresses(oRadComboBoxContext)
    18.  oRadComboBoxItems = oRadComboBoxData.Items.ToList
    19.Catch ex As Exception
    20.  Kcentric.Framework.Diagnostics.Trace.Log(Me.GetType.ToString & "." & New System.Diagnostics.StackFrame().GetMethod.Name, ex)
    21.End Try
    22.Return oRadComboBoxItems
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017