Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
228
Rename a dropdown item
posted

Hi,

 

In my application, I have a web tree that allows the user to change the name.  I also have a web drop down that contains a list of certain items from the tree.  I am trying to, without a postback, update the web drop down when the client changes the tree item name.  The tree item is updated via a JavaScript function that makes a call to a custom web service; and when that web service returns a 'success' state I want to update the drop down with the new item name.

 

Browning inspiration from the sample browser, I wrote this JavaScript function ...

 

 

 

function RenameDDLItem(ddlName, oItem, newName) {

    if (oItem) {

        var combo = $find(ddlName);

        if (combo) {

            var items = combo.get_items();

            for (var index = 0; index < items.get_length(); index++) {

                var item = items.getItem(index);

                if ((item.get_text() == oItem.LocationName) && (item.get_value() == String(oItem.LocationID))) {

                    combo.get_items().getItem(index).set_text(newName);

                }

            }

        }

    }

}

... that is called after the web service responds with a 'success' status.

 

I think I'm on the right track to accomplish my goal, but I either need to do something more or something is preventing me from updating the control.
My scripting does not error out, but it also doesn't rename the item in the drop down.
Any suggestions would be helpfull.
Thanks!
p.s.
I've tried the .remove(item) and .insert(index, item) methods for the item collection and it does update with the renamed value; however, it removes all of the other items from the list.
and this is the aspx code for my dropdown:
                            <ig:WebDropDown ID="wddLocations" runat="server" DropDownAnimationType="Bounce" DropDownContainerMaxHeight="85px"
                                EnableAutoFiltering="Client" EnableDropDownAsChild="False" EnableRenderingAnchors="False"
                                MultipleSelectionType="Checkbox" PageSize="0" StyleSetName="Default" Width="175px"
                                DropDownContainerHeight="85px">
                                <ClientEvents DropDownClosed="MoveCaret" ItemAdded="itemAdded" Focus="wdd_Focus" ValueChanging="wdd_ValueChanging" ValueChanged="wddLocations_ValueChanged" />
                            </ig:WebDropDown>