RADCombobox Remember items even after .clearItems();. Not Displayed on Page. But Uploading on Postback,,Duplicate value Problem

6 posts, 1 answers
  1. Vishmay
    Vishmay avatar
    10 posts
    Member since:
    Feb 2012

    Posted 18 Jul 2014 Link to this post

    Stepwise Explanation

     ddlTest.clearItems();
     ddlTest.trackChanges();
    ddlTest.clearSelection();

       for (var j = 0; j < heat_no.length - 1; j++) {
                                            var comboItem = new Telerik.Web.UI.RadComboBoxItem();

                                            comboItem.set_text(heat_no[j]);
                                            comboItem.set_value(heat_no[j]);

                                            ddl_cast_no.get_items().add(comboItem);
                                        }
      ddlTest.commitChanges();

    1. Above Javascript Code is Executed and My Combobox is filled Perfectly
    2. Now if this Code is executed again it Displays new results that is ok
    3. Let me execute again .. No Problem in Display
    4. I am Making a Postback on server for Some other work
    5. After postback is Shows me my combobox has 3 times duplicated values(Not that we have executed it 3 times).

    If the Code is two times executed the value will be 2 times Duplicate executed
    If the Code is 5 times executed the value will be 5 times Duplicate executed

    I want it Without Duplicate
    Hope You Got My Point
    Reply me as fast as Possible
  2. Vishmay
    Vishmay avatar
    10 posts
    Member since:
    Feb 2012

    Posted 18 Jul 2014 in reply to Vishmay Link to this post

    Sorry about a Bit Mistake and uncomplete information

    ddlTest.clearItems();
     ddlTest.trackChanges();
    ddlTest.clearSelection();
       for (var j = 0; j < heat_no.length - 1; j++) {
                                            var comboItem = new Telerik.Web.UI.RadComboBoxItem();
                                            comboItem.set_text(heat_no[j]);
                                            comboItem.set_value(heat_no[j]);
                                            ddlTest.get_items().add(comboItem);
                                        }
      ddlTest.commitChanges();

    Mistake  ddl_cast_no change to ddlTest

    Note: I have Tried AppendDataBoundItems="true" and "false"
    i m using Telerik.Web.UI_2011_2_712_Dev
    Thanks
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 18 Jul 2014 in reply to Vishmay Link to this post

    Hi Vishmay,

    Unfortunately I couldn't replicate the issue at my end. The provided code is working fine for me. Please have a look into the sample code snippet which works fine at my end. Please provide your full code if it doesn't help.

    ASPX:
    <telerik:RadComboBox ID="RadComboBox1" runat="server">
    </telerik:RadComboBox>
    <telerik:RadButton ID="rbtnAddItems" runat="server" Text="Add Items" AutoPostBack="false"
        OnClientClicked="addItem">
    </telerik:RadButton>
    <telerik:RadButton ID="rbtnPostBack" runat="server" Text="PostBack">
    </telerik:RadButton>

    JavaScript:
    function addItem() {
        var ddlTest = $find("<%=RadComboBox1.ClientID%>");
        ddlTest.clearItems();
        ddlTest.trackChanges();
        ddlTest.clearSelection();
        for (var j = 0; j < 3; j++) {
            var comboItem = new Telerik.Web.UI.RadComboBoxItem();
            comboItem.set_text("Item" + j);
            comboItem.set_value(j);
            ddlTest.get_items().add(comboItem);
        }
        ddlTest.commitChanges();
    }

    Thanks,
    Shinu.
  5. Vishmay
    Vishmay avatar
    10 posts
    Member since:
    Feb 2012

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

    I have Test Your Code on New Page.  And It is having Same Error

    1. I click Add item when Combobox was Empty
    2. Then 3 Items Were Filled. I make Postback -->3 Items(Item 0,1,2)
    3. I Clicked Add item +2 Times (Total 3 Times) --> Checked Display-->3 Items(Item 0,1,2)
    4. Clicked Postback-->Completed postback -->Result was....Check All ScrennShots
  6. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 20 Jul 2014 in reply to Vishmay Link to this post

    Hi Vishmay,

    Please do the following modification in your JavaScript which works fine at my end.

    JavaScript:
    function addItem() {
        var ddlTest = $find("<%=RadComboBox1.ClientID%>");
        ddlTest.trackChanges();
        ddlTest.clearItems();
        ddlTest.clearSelection();
        for (var j = 0; j < 3; j++) {
            var comboItem = new Telerik.Web.UI.RadComboBoxItem();
            comboItem.set_text("Item" + j);
            comboItem.set_value(j);
            ddlTest.get_items().add(comboItem);
        }
        ddlTest.commitChanges();
    }

    Thanks,
    Shinu.
  7. Vishmay
    Vishmay avatar
    10 posts
    Member since:
    Feb 2012

    Posted 22 Jul 2014 in reply to Shinu Link to this post

    Thank You Friend,
    Your suggestion works correctly. Thanks for the help.
    New solution works for me.

    I Dont Know you are Team Member or telerik or not, But Make a favor
    In your new answer, Please Highlight Your Changes or write it below code
    so other reader can identify what change you did in new one.
    and if possible please change title of my topic. it is meaningless.
    i have seen many people working on same problem with diff. Keywords.
    This answer may be helpful to them
    If Possible please change on same post(marked as answer)
    Thanks
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017