Hello,
I have a WebDropDown v11.1 created by code. When it is created, it is empty and I want to fill it with data when another WedDropDown's value is selected. I am using EnableClientRendering="true and JSON to databind on the client side as in your examples. I have no template in my WebDropDown and I don´t know how to set it. I see in HTML you can set a template:
=
"true
<ClientRenderingTemplate>
<ClientRenderingTemplate
>
<li>Product: ${Data}</li>
<
li
>Product: ${Data}</
</
ClientRenderingTemplate
How I can do this by code? Or these is a way to do it by javascript when I am doing the databind?
Can you provide an example where the data are coming from a webservice?
Thanks
Hi there,
Here is an example that shows how you would bind to a service http://samples.infragistics.com/aspnet/Samples/WebDropDown/Data/BindingToHierarchicalJSON/Default.aspx?cn=drop-down&sid=c9dd40d1-0068-483e-88e0-d6fac427ba2a
In the case of the above example the ajax call is intercepted by mockjax to simulate receiving data via an $.ajax call. Also there is a public function in the javascript API: set_clientTemplate('client template') which you can use in order to set the template before calling the dataBind() method.
Let me know if this example is of any help to you!
Hi,
I have the following problem:
If I have a webdropdown in a aspx page, when the application is running, the source code generated is:
...
<div id="x:140540991.5:mkr:DropDown" class="igdd_FullstepPMWebDropDownListContainer " style="display:none;visibility:hidden;">
<div id="x:140540991.6:mkr:DropDownContents" style="overflow:auto;height:200px;width:400px;">
<ul id="x:140540991.7:mkr:List:nw:1" class="igdd_FullstepPMWebDropDownList ">
<li><a>${Text}</a></li>
</ul>
</div>
Everything works perfectly!
But when I insert the control by code, such as
Dim oDrpDwn As Infragistics.Web.UI.ListControls.WebDropDown
oDrpDwn = New Infragistics.Web.UI.ListControls.WebDropDown
oDrpDwn.EnableClientRendering = True
…
The code generated it hasn´t got any <LI> element!! So when I databind the data, I get no errors but the webdropdown is empty. Why is this?
That is why I think I need to set a template (or something similar), because I don´t have it. I see the webdropdown element has a set_template method. How can I use it? Is there other solution?
Thanks for your help!
Hi again,
I can't seem to reproduce this issue. I dynamically create a WebDropDown on Page_Load and it renders fine and all the HTML is the same as if I have declared it in the aspx. As I mentioned above you would have to use set_clientTemplate and provide a jQuery template to the function (using jQuery templating plugin), however this is done if you're binding your drop down to JSON data.
Did you catch the DataBinding event and call databind after providing the datasource?
I will be looking forward to your response!
Yes, it is true. Sorry! There was something wrong in my code. It´s renders OK now.
I am binding my dropdown to JSON data (from a webservice) and it works fine. But I still would like to use a template.
I haven´t found too much about the “set_ClientTemplate” you mentioned.
I don’t know very much about jQuery. For example, I have a template:
<script id="MyTemplate" type="text/x-jquery-tmpl">
<li><b>${Name}</b> (${Year})</li>
</script>
The .tmpl() method is designed for chaining with .appendTo, .prependTo, .insertAfter or .insertBefore, but I don´t know how to chain it to the webdropdown control. could you provide an example? What is "setTemplate" method for?
Thank you in advance.
Hi again alfmag,
That was my bad, in fact the method is called set_template and you provide the markup for your template to it the following way:
sender.set_template( '<li><b>${Name}</b> (${Year})</li>');
However, while I was playing with it I found a small issue which I have fixed, but it will appear in future service release. I suggest you contact developer support in order to receive information on how you can acquire this fix before the actual service release.
Thank you very much for your patience and for using the Infragistics forums!
Hi alfmag,
Just wanted to let you know that the service release went out and the fix is included in it :)
Best regards,