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

Custom editor / template functions in SPA pattern.

1 Answer 27 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Greg
Top achievements
Rank 1
Greg asked on 03 Feb 2014, 06:06 PM
I am following the MVVM SPA pattern using kendo views and kendo router. Also, I am using RequireJS to load my js modules and html templates.

One of my templates is a simple kendo.Grid:

<DIV id="a-grid"
data-role="grid"
data-bind="source: source, events: { dataBound: dataBound, change: change }"
data-columns='[
{ "field": "aID", "title": "A", template: "#=aName( aID )#", editor: aEditor }]'>
</DIV>

It binds correctly to the source, event functions, and displays data. 
I got to work the template function by defining it in the window context:

window.aName = function ( aID ) { ... return name; };
Although, I don't like putting it into global context.

How can I define the editor and template functions in my js modules?

Thanks,

Greg.

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 05 Feb 2014, 09:41 AM
Hello Greg,

In case the Grid is initialized with data attributes the columns.editor function should be accessible from the global scope. It is possible to set it as a property of an object, but the object itself should be accessible from the global scope. For example:

window.editors.aName = function ( aID ) { ... return name; };
  
editor: editors.aName


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
Grid
Asked by
Greg
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or