Solved

Kendo UI multiselect Asp.Net

Posted on 2014-02-20
2
1,607 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
ID: 39876565
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
ID: 39877165
Perfect. Thank you
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
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…

820 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