Telerik ComboBox get_items().add(item) not binding value at server

2 posts, 0 answers
  1. naman
    naman avatar
    1 posts
    Member since:
    Sep 2020

    Posted 29 Sep Link to this post

    As i'm binding value in client site for combobox like this way in Jquery.

    $.each(response, function (index, value) {
    let item = new Telerik.Web.UI.RadComboBoxItem();
    item.set_text(value.EnggName);
    item.set_value(value.EngineerId);
    $find('<%= cmb_EnggList.ClientID%>').get_items().add(item);
    });

    and it binds the value correctly but when i post it in the server like this.

    foreach (Telerik.Web.UI.RadComboBoxItem EngineerId in cmb_EnggList.Items)// it gives empty items
    {
      if (EngineerId.Checked)
      {
           Guid GuidEngineerId = new Guid(EngineerId.Value);
          _JobCalendarEngg = new JobCalendarEngg();
          _JobCalendarEngg.JobCalendarEnggId = Guid.NewGuid();
          _JobCalendarEngg.JobCalendarId = JobCalendarId;
          _JobCalendarEngg.EngineerId = GuidEngineerId;
          en.JobCalendarEnggs.Add(_JobCalendarEngg);
      }
    }
    It gives me empty 
    cmb_EnggList.Items
     but when i bind it like this.

    cmb_EnggList.Items.Clear();
    foreach (var record in records)
    {
       var EnggName = (from k in en.EngineersLibraries
       where k.EngineerId == record.EngineerId select k).FirstOrDefault(); Telerik.Web.UI.RadComboBoxItem item = new
       Telerik.Web.UI.RadComboBoxItem(EnggName.EngineerName, EnggName.EngineerId.ToString());
       cmb_EnggList.Items.Add(item);
    }

    And post it will give me binded value so in the whole scenario if i bind my drop down in Jquery it binds value in the client page and after post method it gives me an empty list but when i bind the drop down in my server end and when i post it will get me the binded list.
    So i require my Jquery binded value to be get in my server list. f
    oreach (Telerik.Web.UI.RadComboBoxItem EngineerId in cmb_EnggList.Items)
  2. Doncho
    Admin
    Doncho avatar
    71 posts

    Posted 02 Oct Link to this post

    Hi Naman,

    In order to access any changes performed client-side at the server, you will need to you need to call the trackChanges() and commitChanges() client methods of RadComboBox, see Accessing Client Changes at the Server.

    You can also check out the approach shown in the Add Item section in our Working with Items in Client-Side article:

    function addNewItem() {
        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();        
    }
    I hope this will prove helpful. Please let me know if any questions come up!

    Kind regards,
    Doncho
    Progress Telerik

    Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

Back to Top