Custom Widget user templating

4 posts, 0 answers
  1. Matjaz
    Matjaz avatar
    94 posts
    Member since:
    Jun 2014

    Posted 28 Jul 2014 Link to this post

    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?
  2. Petyo
    Admin
    Petyo avatar
    2438 posts

    Posted 30 Jul 2014 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
  4. Matjaz
    Matjaz avatar
    94 posts
    Member since:
    Jun 2014

    Posted 31 Jul 2014 in reply to Petyo Link to this post

    Went through several times.
    Any hint where to look?
  5. Petyo
    Admin
    Petyo avatar
    2438 posts

    Posted 04 Aug 2014 Link to this post

    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!
     
Back to Top
Kendo UI is VS 2017 Ready