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

Grid calling function from template

3 Answers 1558 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 2
Ryan asked on 27 Apr 2012, 02:03 PM
This should be simple but it appears that the local function cannot be found from a template.  
What's missing?

See  http://jsfiddle.net/JVPa5/2/ 

...
template'#= Simple(OffDuty,OnDuty); #' 
...
function Simple(a,b){
     return 100                     
} 



3 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 27 Apr 2012, 02:42 PM
Hi Ryan,

The sample fails due to the fact that in this setup the code put in the JavaScript pane is actually placed within the onLoad handler, thus the Simple function is in different of the global scope. Setting either of the two no wrap options from the left dropdown menu should fix the issue.

Also note that you should remove the semicolon after the Simple function call within the template as it is not valid.

All the best,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Ryan
Top achievements
Rank 2
answered on 27 Apr 2012, 05:41 PM
I implemented your suggestions http://jsfiddle.net/JVPa5/4/ and it completely fails now ?  

?? global scope.. OnLoad is after because that should be more inclusive after all the script is loaded.    
0
Rosen
Telerik team
answered on 02 May 2012, 12:05 PM
Hello Ryan,

Indeed, if you set it to header you should execute the initialization code into document ready event. I have modified the jsFIddle to demonstrate this. Also note that the div element is not a self closing tag and using is as such will yield invalid html.

Greetings,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Ryan
Top achievements
Rank 2
Answers by
Rosen
Telerik team
Ryan
Top achievements
Rank 2
Share this question
or