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

Custom Widget user templating

3 Answers 63 Views
Templates
This is a migrated thread and some comments may be shown as answers.
Matjaz
Top achievements
Rank 1
Matjaz asked on 28 Jul 2014, 09:53 AM
My code is:
var MatjazChooser = kendo.ui.Widget.extend({
         
        init: function(element, options) {
            var that = this;
         
            kendo.ui.Widget.fn.init.call(that, element, options);
             
            that.wrapper = that.element;
            element = that.element;
            element.addClass('k-chooser');
 
            var template = that.options.template;
            if (template == "")
            {
                template = '<span class="k-button" data-group="# if (data.group != undefined) { ##=data.group##} else {#default#}#" data-uid="#= data.uid #">';
                template += '# if (data.imageUrl != undefined) { #';
                template += '<img src="#= data.imageUrl #"><br>';
                template += '#}#';
                template += '#= text #';
                template += '</span>';
            }
            that.template = kendo.template(template);
     
            that._dataSource();               
        },
The important line is: data-uid="#= data.uid #
If the user (programmer) defines template without uid, the Widget will not work as expected.

How can I check if user define template with data-uid, or not? How can I added it, if not exists?

3 Answers, 1 is accepted

Sort by
0
Petyo
Telerik team
answered on 30 Jul 2014, 07:00 AM
Hi Matjaz,

you can check how the same problem is resolved in the source code of the listview widgets (both mobile and desktop version). 

Regards,
Petyo
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Matjaz
Top achievements
Rank 1
answered on 31 Jul 2014, 11:19 AM
Went through several times.
Any hint where to look?
0
Petyo
Telerik team
answered on 04 Aug 2014, 07:26 AM
Hi Matjaz,

The following method is how the mobile listview builds its template.

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