Rest of my application uses proper javascript naming convention (i.e. camel case with lower first character).
Is there a way to configure MVC Helpers to output javascript that would conform to proper javascript naming convention? I have configured JSON serialization at the root of my application, and would rather not change my naming convention just to conform to Telerik's way.
6 Answers, 1 is accepted
There is no officially supported way to change that. What you see is the default behavior of the JavaScriptSerializer - it serializes .NET properties as they are. The naming convention for .NET properties is to start with capital letter - this is why they are serialized like this.
On a side the JSON response should be handled automatically by the grid. You should not be involved with using the properties of the response at all.
If this is bothering you too much you could modify the source code. Renaming the properties of DataSourceResult and modifying DataSourceSchema should be enough. However have in mind that we do not support such modifications.
Atanas Korchev
the Telerik team
Do you mean change source code of DataSourceSchema? If that's the case, where do I get source code for DataSourceSchema?
I also see that DataSourceSchema has public properties to change json property names (i.e. "Data", "Error", "Total"), how do I change those values when I create grid in .cshtml?
@(Html.Kendo().Grid<IssueListEntryViewModel>()
.Name("NewIssues")
.Columns(columns => {
columns.Bound(p => p.Id).Title("Id");
})
.DataSource(ds => ds
.Ajax()
.Read(read => read.Url(Model.FooUrl))
)
)
Yes, you need to use the source code. It is shipped in the src directory of the distribution. You can't set the schema properties via fluent API because they are not exposed.
The JSON serializer shipped with asp.net MVC 4 works in the exact same way as the JavaScriptSerializer - preserves the casing of the properties.
Atanas Korchev
the Telerik team
You must download Kendo UI Complete for ASP.NET MVC commercial. It contains the src directory.
Greetings,Atanas Korchev
the Telerik team