I have recently installed VS2012 and there I have Kendo 2012.3.1114. I just copied all the code from the VS2010 to VS2012 and it all just worked except for one small point. I have a nested grid and I use a template for the detail. That template is shown below. It works fine in the 2010 project but 2012 always says "Uncaught Error: Invalid template:" and the template is identical. If I comment out the .ClientTemplateId statement, the main grid displays just fine. If I paste the template into its own Partial View and display it separately, it displays just fine but it always errors as a template.
I have tried commenting out parts of the template, even getting to the point where it o nly has the Name and ToClientTemplate calls and it STILL errors. So I just wonder if something is broken with templates in the latest version of Kendo or the latest version of VS. The template is below:
Any help much appreciated.
9 Answers, 1 is accepted
I've looked through it but can't see anything wrong with it, but maybe you guys have better tools for pulling apart generated templates.
This is pretty urgent for me since I can't even see a work around.
The reason for the problem is the AntiXssEncoder which is enabled in the Web.config httpRuntime configuration:As can be seen in the template, all spaces are encoded and the "#" character is included which breaks the templates parsing. Removing it should resolve the problem.
the Telerik team
The pros for the helpers would be that they enable intellisense and compile time checking of variable names and they can use Reflection to know more about the fields being encoded. But a possible con is that it may not be possible to code everything in a helper that is possible in the html. At the very least the helper might lag a release behind the html upgrades. I'm interested in people's thoughts on this.
Also, what are the implications of turning of the AntiXssEncoder and is it possible to turn it off just for some pages?
Thanks for your feedback.
Yes, not everything possible with Kendo UI Web/DataViz is possible with the MVC wrappers because they are configured to work with the MVC Controllers and not all options can be set.
Regarding the encoder - by default MVC uses the HttpEncoder so the application should still be protected from cross-site scripting attacks. It is possible to change the encoder in a particular view by setting the current encoder("System.Web.Security.AntiXss.AntiXssEncoder.Current") but this will change the encoder for the entire application as well.
It is also possible to specify the characters that does not need to be encoded with the MarkAsSafe method though I have not found a way to allow spaces in the attributes which is the reason for the error in most cases.
the Telerik team
I've opened a support ticket to get it included in the next release. Feel free to lean on them as well.
I checked my web.config, there is no reference to AntiXssEncoder.
Here is my client detail template:
I know the problem with my template is here $('#IncompleteTrains_\#=Id\#')
Is this not the correct way to reference it?
You should escape the character used for the id selector instead of the ones used for the template expression:On a side note, the save event is called in the context of the Grid so you do not need to find the element in order to call its or its dataSource methods: