I have the following in a template <script type="text/x-kendo-tmpl" id="documentDetailsTemplate"></script>
@(Html.Kendo().MultiSelect()
.Name("otherParties")
.DataSource(ds =>
{
ds.Read("GetOtherParties", "Term", new { SPHostUrl = ViewBag.SPHostUrl });
})
.DataValueField("TermId")
.DataTextField("Label")
.AutoBind(false)
.HtmlAttributes(new { style = "width:100%" })
.Placeholder("Select Other Parties...")
.ItemTemplate("<
div
class=\"k-state-default term-label\">\\#= data.Label \\#</
div
><
div
class=\"k-state-default term-path\">\\#= data.Path \\#</
div
>")
.Value("#: OtherParties #")
.MinLength(3)
.Filter(FilterType.Contains)
.ToClientTemplate())
The OtherParties property is a List of classes as detailed in the code snippet below.
public
class
TermItem
{
public
Guid TermId {
get
;
set
; }
public
string
Label {
get
;
set
; }
public
string
Path {
get
;
set
; }
}
public
List<TermItem> OtherParties {
get
;
set
; }
The template is then passed with a dataItem in javascript using the code below.
var
documentList = $(
"#documentsList"
).data(
"kendoListView"
);
var
dataSource = documentList.dataSource;
var
document = dataSource.getByUid(documentList.select().attr(
"data-uid"
));
var
template = kendo.template($(
"#documentDetailsTemplate"
).html());
Have checked with Fiddler and the values are coming back correctly. Have debugged the JavaScript and the document object in the snippet above has the values in it.
The documentation at http://docs.telerik.com/kendo-ui/aspnet-mvc/helpers/multiselect/overview#pre-select-values-on-initial-load says that you need to select it with a List<class> object.
It's not pre-selecting the values when the template is generated.
Any ideas on what is the correct way to do this?