Solved

Kendo UI multiselect Asp.Net

Posted on 2014-02-20
2
1,567 Views
Last Modified: 2014-02-21
Hello Experts,
I am new to Kendo UI. I want to bind the Multiselect control from my sql table.


<div class="demo-section">
                <h2>
                    Invite Attendees</h2>
                <label for="required">
                    Required</label>
                <select id="required" multiple="multiple" data-placeholder="Select attendees..." class="mySelect">
                  
                </select>
                 <button class="k-button" id="get">Send Invitation</button>
            </div>

Open in new window



 $.ajax({

                        // the url to the service
                        url: "api/LocalContact",

                        // the format that the data should be in when
                        // it is returned
                        contentType: "json",

                        // the function that executes when the server
                        // responds to this ajax request successfully
                        success: function (data) {
                            $.each(data, function (index, item) {
                                alert(item.Name);
//getting items here but are not binded to multiselect
                                $(".mySelect").append('<option>' + item.Name + '</option>')

                            });
                        } //end of success
                    }); //end of ajax



                    var required = $("#required").kendoMultiSelect().data("kendoMultiSelect");

                    var all = $.map(required.dataSource.data(), function (dataItem) {
                        return dataItem.value;
                    });

                    required.value(all);

                    $("#get").click(function () {
                        alert("Attendees:\n\nRequired: " + required.value());
                        return false;
                    });

Open in new window

0
Comment
Question by:johny_bravo1
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
Comment Utility
What about :
		var required = null;

		$.ajax({
			url: "api/LocalContact",
			contentType: "json",
			success: function(data) {
				$.each(data, function(index, item) {
					$("#required").append('<option>' + item.Name + '</option>')
				});
				required = $("#required").kendoMultiSelect().data("kendoMultiSelect");
				var all = $.map(required.dataSource.data(), function (dataItem) {
					return dataItem.value;
				});
				required.value(all);
			}
		});

		$("#get").click(function() {
			alert("Attendees:\n\nRequired: " + required.value());
			return false;
		});

Open in new window

0
 
LVL 8

Author Closing Comment

by:johny_bravo1
Comment Utility
Perfect. Thank you
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now