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);
}
Hi Angel,
Thanks for the reply. The _element.innerHTML allowed me to change the text; however when I select the modified item from the drop down (at a later action) the text that populates the input box is the old value.
For now, I'll have to leave this as a 'known issue' in our application and keep an eye out for the update for the .set_text(..) method.
Again, thank you for your assistance.
You aren't doing anything wrong. Calling set_text(..) on the item will update its state, and on the subsequent ajax request or postback, the new markup will have the updated texts. That's because the item may have more than text, i.e. it may be a templated item with contents generated on the server, so it may not be possible to update the markup by just using innerHTML on the client-side. If you'd like to achieve that by calling set_text directly, i suggest to add this line after call to set_text()
item._element.innerHTML = "new text";
I agree that in the simplest case, where your item has only text, it's more intuitive to have that automatically done by set_text(). I will submit an issue for that and have it fixed.
Thanks,
Angel