Hello,
I am using IG version 17.2 with VS 2012. I have a databound WebDropDown in MultiSelect mode. What I am trying to accomplish is: Allow the user to enter a new item into the DropDown control and SQL database table, select that item, then display the new item in the DropDown text. I will deeply appreciate any help on how I can accomplish this or if it's possible.
Please find attached my sample solution and database samples attached.
Thank you,
Thank you Alex,
That worked great. I did not remove the "Seafood" item from the list, I simply moved the code that added the new item to the dropdown after the unselect() method on the seafood item as your code shows.
Hi,
I have updated the sample and I believe this will resolve your entire scenario now. Please, give it a try and let me know if this is working fine on your end.
Basically, this is the change inside the "for" loop:
for (j = 0; j < FTEItems.length; j++) { if (FTEItems[j].get_text() == "Seafood") { FTEItems[j].unselect(); var strValue = FTEcombo.get_currentValue(); var newValue = strValue.replace("Seafood", newFTEName); FTEcombo.set_currentValue(newValue, true); FTEcombo.get_items().remove(FTEItems[j]); var item = FTEcombo.get_items().createItem(); item.set_text(newFTEName); item.set_value(newFTEName); item.set_selected(true); FTEcombo.get_items().add(item); } }
WebDropDown_Sample_Updated.zip
If you have additional questions or issues on this scenario, do not hesitate to contact the Infragistics support again!
Thank you once more for using Infragistics ASP.NET!
Best regards, Alexander
Hi.
I wanted to inform you that we are working on the latest scenario and we trying to reproduce the problem. We will write you as soon as possible. Thank you for the patience!
Best regards,
Nikolay Alipiev
Thank Alex,
Your example works fine and thank you for the tip about including the "true" pararameter in the set_currentValue method. However, in my project the results are inconsistant. The "Other" item sometimes get unchecked and other times it doesn't. I also sometime get the error message "Server not responding" when the set_currentValue method is envoked. The new value is being added to the list but not being selected and not replacing the "Other" text in the dropdown display. Do you suppose it has something to do with the add_item method?
//Add the new FTE Name to the client dropdown and select it. if (response.length > 0) { var idpos = response.indexOf("|"); var newid = response.substring(0, idpos); var item = FTEcombo.get_items().createItem(); item.set_text(newFTEName); item.set_value(newid); FTEcombo.get_items().add(item); var itemIndex = item.get_index(); FTEcombo.selectItemByIndex(itemIndex);
Thanks,
Thank you for your response!
I think I managed to execute the desired scenario. What you need is to provide a second argument to the "set_currentValue" method. This argument is about if the current value should be copied to the input. Basically, you were successfully updating the actual value of the control but the input was not reflecting this change.
So, your line should look like this:
FTEcombo.set_currentValue(newValue, true);
About your other issue – the “Other” checkbox not being unchecked – I am not able to reproduce this behavior. The checkbox is unchecked after executing
FTEItems[j].unselect();
I am attaching a simplified solution that demonstrates this scenario. This is not saving the new item to the database and is just updating the value in the input. In my example I use the “Seafood” item as the “Other” item in your scenario.
If you have further issues with this scenario do not hesitate to contact the Infragistics support again.
Also, if the “Seafood” item is not unchecked when running the example on your machine – please let me know.
Best regards, Alexander MarinovWebDropDown_Sample.zip