Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Kendo UI multiselect Asp.Net

Posted on 2014-02-20
2
Medium Priority
?
1,675 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 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

Amazon Web Services EC2 Cheat Sheet

AWS EC2 is a core part of AWS’s cloud platform, allowing users to spin up virtual machines for a variety of tasks; however, EC2’s offerings can be overwhelming. Learn the basics with our new AWS cheat sheet – this time on EC2!

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
Suggested Courses

722 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