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 wfx,
Thank you for posting in the community.
If your requirement is to add a new row in the templated table inside an item's container, this can be achieved by accessing the dropdown item's element, for istance:
ig_controls.WebDropDown1.get_items().getItem(0).get_element().children[0].insertRow(0).insertCell(0).textContent = 'This is a new cell in a new row';
More information and instructions on how to add items in WebDropDown client-side may be found at:
http://blogs.infragistics.com/forums/p/27710/253640.aspx
Please let me know if this helps.
Hi Petar,
Thanks for your quick reply.
Unfortunately the solution provided by you did not work as it is saying that method "insertRow()" is undefined.
I also tried the below piece of code which workd for me but giving an error while selecting that newly added item. Please have a look and let me know how can I fix this.
function addItem() {
var combo = $find('ddlOrder');
var item = combo.get_items().createItem();
var html_item ="<table style='width: 100%; border-collapse:collapse' cellspacing='1' cellpadding='0' border='0'><TBODY><tr class='clsRowDataLabel' height='25'><td width='20%'>999999</td><td width='20%'>Sample Style</td><td width='20%'>PAC9999</td><td width='20%'>99999</td><td width='20%'>4/5/2012 12:00:00 AM</td><td style='display: none'>999999~Sample Style~PAC9999~99999</td><td style='display: none'>99999</td></tr></TBODY></table>";
item.set_text(html_item);
item._element.innerHTML=html_item;
item.set_value(
'99999');
combo.get_items().add(item);
//combo.get_items().getItem(0).get_element().children[0].insertRow(0).insertCell(0).textContent = 'This is a new cell in a new row';
}
Thanks for your reply.
I am using the below Infragistics assembly :
<%@ Register Assembly="Infragistics35.Web.v9.1, Version=9.1.20091.2164, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb"Namespace="Infragistics.Web.UI.ListControls" TagPrefix="ig" %>
Please advise,
Regards,
Tasleem Arif WFX
Hi Tasleem,
Thank you for your reply.
I have tested my sample with your version, however the event argument's value is still accessible and not null as expected. Any additional information such as whether the dropdown is nested in some other controls may help to isolate the matter. A small sample page would be greatly appreciated.
Please find attached my aspx file and let me know why I am getting undefined on below line-
combo.get_items().getItem(0).get_element().children[0].insertRow(0).insertCell(0).textContent = 'This is a new cell in a new row';
Thank you for the sample.
It appears that the new item's element is not initialized/created in time for you to be able to access it immediately after adding it to the dropdown. I would therefore suggest using the javascript setTimeout:
For instance:
Please feel free to contact me if you have any questions.
I tried your code using setTimeout() but that did not work for me.
Tasleem Arif
WFX