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

Grid toolbar MVVM doesn't work

3 Answers 276 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 05 Apr 2016, 02:36 AM

The toolbar template here does not work when everything to be known about kendo and templates, suggest it should.

Can anyone explain why the MVVM toolbar here is an invalid template? Especially given the data-editable element below, works perfectly, suggesting everything is as it should be.

...

data-toolbar="[{ template: kendo.template($('\\#user-list-toolbar-template').html()) }]" 
data-editable="{ mode: 'popup', template: kendo.template($('\\#user-edit-dialog-template').html()) }"

 

<script id="user-list-toolbar-template" type="text/x-kendo-template">
<a class="k-button k-button-icontext k-grid-add" href="#"><span class="k-icon k-add"></span>A</a>
<a class="k-button k-button-icontext add-ad-user" href="#"><span class="k-icon k-add"></span>B</a>
</script>

 

<script id="user-edit-dialog-template" type="text/kendo-ui-template">

... this one works, no issues, no need to see anymore

3 Answers, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 06 Apr 2016, 04:26 PM
Hello Peter,

The data-template attribute accepts a string representing the template ID. For example:

data-toolbar="user-list-toolbar-template"



Regards,
Alexander Valchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Peter
Top achievements
Rank 1
answered on 07 Apr 2016, 12:04 AM

Perhaps I'm on an older version Kendo UI v2015.3.1214

Doing as you suggest, simply shows the string "user-list-toolbar-template" in the toolbar.

0
Alexander Valchev
Telerik team
answered on 08 Apr 2016, 04:20 PM
Hi Peter,

My previous reply was misleading. Please accept my apology!

The way template is defined is indeed correct. The invalid template error occurs because there are unescaped hash symbols (#) in the template.

<script id="user-list-toolbar-template" type="text/x-kendo-template">
  <a class="k-button k-button-icontext k-grid-add" href="#"><span class="k-icon k-add"></span>A</a>
  <a class="k-button k-button-icontext add-ad-user" href="#"><span class="k-icon k-add"></span>B</a>
</script>


The template should look like:

<a class="k-button k-button-icontext k-grid-add" href="\#"><span class="k-icon k-add"></span>A</a>
<a class="k-button k-button-icontext add-ad-user" href="\#"><span class="k-icon k-add"></span>B</a>


I also prepared a working test page: http://dojo.telerik.com/AzULE

Regards,
Alexander Valchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
MVVM
Asked by
Peter
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Peter
Top achievements
Rank 1
Share this question
or