Inherit kendo widgets using TypeScript

Need to extend or create your own custom widgets derived from Kendo UI? Here’s a simple blank widget that you can use to get started with creating your own JQuery Kendo ui plugins that can support kendo MVVM and templates.

 

///<reference path='references.ts' />

//Simple blank jquery plugin. copy file and find replace EmptyTemplate with the name of ur new plugin
// jQuery auto complete for widget creation.
interface JQuery {
    kendoEmptyTemplate(options?: KendoWidgets.IEmptyTemplateOptions): JQuery;
    data(key: "kendoEmptyTemplate"): KendoWidgets.EmptyTemplateOptions;
}

module KendoWidgets {

    export interface IEmptyTemplateOptions {
        
    }

    export class EmptyTemplateOptions implements IEmptyTemplateOptions{
        name: string = 'EmptyTemplate';
    }
    
    export class EmptyTemplate extends kendo.ui.Widget
    {
        options: EmptyTemplateOptions;



        constructor(element: Element, options: IEmptyTemplateOptions) {
            super(element, options);

        }
            
    }

    // Create an alias of the prototype (required by kendo.ui.plugin)
    EmptyTemplate.fn = EmptyTemplate.prototype;
    // Deep clone the widget default options
    EmptyTemplate.fn.options = new EmptyTemplateOptions();
    // Create a jQuery plugin.
    kendo.ui.plugin(EmptyTemplate);
}

Submit a Comment

Your email address will not be published. Required fields are marked *

Share This