This is a migrated thread and some comments may be shown as answers.

ItemTemplate when Multiselect used in CustomTemplate

2 Answers 151 Views
MultiSelect
This is a migrated thread and some comments may be shown as answers.
SrcDev
Top achievements
Rank 1
Iron
SrcDev asked on 11 Dec 2017, 03:03 PM

Hi,

I am trying to change the ItemTemplate for a Multiselect which is used inside a CustomEditorTemplate for a Kendo Scheduler. 

The multiselect is initialized as follows:

<code>

@(Html.Kendo().MultiSelectFor(model => model.Predavatelji_Ids)

          .HtmlAttributes(new { data_bind = "value:Predavatelji_Ids" })
          .Name("Predavatelji_Ids")
          .DataValueField("Id")
          .DataTextField("Ime")
          .Filter("contains")
          .AutoBind(true)
          //.Value(Model.Predavatleji)

          .DataSource(source =>
          {
              source.Read(read =>
                  read.Action("Avtorji_Dropdown", "Avtorji").Data("additionalInfo")
                  )
                .ServerFiltering(true);
          }).Events(e => e.Open("validatePredmentInput"))
           .ItemTemplate("<span class=\"k-state-default\"><h3>#: console.log(data) #</h3><p>#= data.Ime #</p></span>")
    )

</code>

But calling the data object inside the ItemTemplate returns the Model object for the current Scheduled event and not the Multiselect item.

What am I missing?

 

2 Answers, 1 is accepted

Sort by
0
SrcDev
Top achievements
Rank 1
Iron
answered on 12 Dec 2017, 09:00 AM
I was missing escaping the "#" characters so the expression was evaluated in the parent context. 
0
Accepted
Dimitar
Telerik team
answered on 13 Dec 2017, 02:06 PM
Hello Mojca,

If your template includes a # character, which is part of a binding expression of a nested template, then this character must be escaped with "\\#". You can checkout the Templates Overview Documentation, where this is described with additional examples.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
MultiSelect
Asked by
SrcDev
Top achievements
Rank 1
Iron
Answers by
SrcDev
Top achievements
Rank 1
Iron
Dimitar
Telerik team
Share this question
or