This is a migrated thread and some comments may be shown as answers.
Creating Telerik Dropdown control dynamically
2 Answers 56 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Prashant
Top achievements
Rank 1
Prashant asked on 21 Mar 2012, 12:59 PM
Hi, I am using MVC 3 and trying to create telerik Dropdown control dynamically through JQuery or Javascript at runtime on link button click .Please guide me.Thanks in advance.

2 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 23 Mar 2012, 10:35 AM
Hello Prashant,

Such functionality is not supported. Neverthless, if you have included all the needed scripts you can render the needed HTML and then call our initialization function.
e.g.
HTML:
<div class="t-widget t-dropdown t-header" style="width:200px" tabindex="0">
        <div class="t-dropdown-wrap t-state-default">
            <span class="t-input">Chai</span>
            <span class="t-select">
                <span class="t-icon t-arrow-down">select</span>
            </span>
        </div>
        <input id="DropDownList" name="DropDownList" style="display:none" type="text" value="1">
</div>
the init function:
$('#DropDownList').tDropDownList({
                    data: [{
                        "Text": "Chai",
                        "Value": "1"
                    },
                    {
                        "Text": "Chang",
                        "Value": "2"
                    },
                    {
                        "Text": "Aniseed Syrup",
                        "Value": "3"
                    },   
                    {
                        "Text": "Original Frankfurter grüne Soße",
                        "Value": "77"
                    }]
                })



Kind regards,
Petur Subev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
0
Gerard
Top achievements
Rank 1
answered on 09 Apr 2012, 02:40 PM
I had the same problem, and your code works fine, thanks. However, I have an issue when I apply the tDropDownList method on an element that I cloned with the jQuery clone method. In the previous example, I would clone the containing div, and then change the id and name properties of the hiddent input. There is no error, but the list is not filled. Would you have any suggestion? It seems that some initialization is missing.

Thanks

Update: please ignore, it works: I had a typo in my code!
Tags
ComboBox
Asked by
Prashant
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Gerard
Top achievements
Rank 1
Share this question
or