Hi,
I am using a WebDropDown with a custom table template.
I just want to add a new template item at cliet side using javascript or jQuery.
Please suggest.
My aspx page code given below :
="DropDown"
="true"
="false"
="OrderID">
>
="1"
='clsHeaderDate'>
="20%">
="0">
="25">
<%
)%>
="display: none">
="dllSelectionChange"/>
Hi Tasleem,
Thank you for your reply.
Please provide me with your precise product version as I am unable to reproduce the behavior using version 11.2.20112.1019. Can you confirm whether the issue is reproducible with the sample I have provided ?
Hi Petar,
Thanks for your reply.
As per your suggestion I am using the below code :
function addItem() { var combo = $find('WebDropDown1'); var item = combo.get_items().createItem(); item.set_text("999999"); item.set_value('999999'); combo.get_items().add(item);}
function WebDropDown1_ItemAdded(sender, eventArgs){ eventArgs.get_value().get_element().children[0].rows[1].cells[0].textContent = "My Text";}
Unfortunately eventArgs.get_value() is giving me "undefined" in ItemAdded event.
Please advice,
Tasleem Arif
WFX
Hi wfx,
Note that the when adding an item in WebDropDown, the item template is not accessible and is not in fact instantiated until after the ajax callback made to the server. To modify the contents of the new item's template I suggest that you use the ItemAdded client-side event.
The templated elemets for a particular item may be accessed via the get_element() function:
function WebDropDown1_ItemAdded(sender, eventArgs){ eventArgs.get_value().get_element().children[0].rows[1].cells[0].textContent = "New text for second line of new item";}
Please let me know if this helps.
Thankx for your reply.
The code you have sent is only helpful if we add a new item with single table cell.
I your code there are three table cells in the item template and you are only setting text for the first cell, what about rest two cells? How can we set text for other two cells ?
Please have a look to my item template with 7 cells and I wanted to add a complete row with new values :
<ItemTemplate>
</
ItemTemplate>
Please reply.
Thanks
Tasleem Arif Idrisi
<
<table style="width: 100%; border-collapse:collapse" cellspacing="1" cellpadding="0" border="0"
</tr
ItemTemplate
It is not necessary to inject html as the text of the new item as adding the item would instantiate the item template (an AJAX callback would be made). Attached is a sample demonstrating such a setup.
Please feel free to contact me if you have any questions.