There are several questions for using MultiSelect in grids:
- The grid editor only supports the column types
string , boolean , number and date . Since you need to save the array ... let's say string , you have to get around this. - Since you are getting an array of values from the server, you will need to use
template to serialize it to string in order to display the values received from the server. - KendoUI cannot guess that you want to use MultiSelect as input, so you need to provide an
editor function as well.
Let's look at all these issues:
To solve the question of array of string , the simplest solution tells KendoUI nothing about what it gets.
For template , I'm going to use the JavaScript join method to pull all the values together, separated by the "," character. Something like:
{ field: "Cities", template: "#= Cities.join(', ') #" }
Finally, for the editor, I use:
{ field: "Cities", template: "#= Cities.join(', ') #", editor : citiesEditor } function citiesEditor(container, options) { $("<select multiple='multiple' data-bind='value : Cities'/>").appendTo(container).kendoMultiSelect({ dataSource: citiesDS }); }
Where in my case citiesDS is just an array of string with the name of valid cities.
var citiesDS = [ "Boston", "Kirkland", "London", "New York", "Philadelphia", "Redmond", "Seattle", "Tacoma" ];
When you update (save), it sends the host a array strings with the cities entered in the Cities field.
Example: here http://jsfiddle.net/OnaBai/Q2w7z/
Onabai
source share