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

How to use the CamelCase formatting for a column

1 Answer 666 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Semenov
Top achievements
Rank 1
Semenov asked on 18 Sep 2017, 12:19 PM

I have a data on a server with the CalbelCase formatting for properties. How bind column to model via lambda expression?

This example demonstrates this:

@(Html.Kendo().Grid<WebApplication66.Models.Contact>()
    .Name("Grid")
    .Columns(columns => {
        columns.Bound(m => m.Name);
        columns.Bound(m => m.Price);
    })
    .DataSource(d => d
        .WebApi()
        .Model(model => {
            model.Id(m => m.Key);
            model.Field(m => m.Name);
        })
        .Read(read => read.Action("Get", "Contacts"))
    )
)

My JSON form WebApi controller:

{"data":[{"name":"Test Name","price":100,"key":0},{"name":"Test Name 2","price":1,"key":1}],"total":2,"aggregateResults":null,"errors":null}

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 21 Sep 2017, 06:08 AM
Hello, Semenov,

In this scenario, if the model or the field names cannot be changed I can suggest using custom dataSource and its schema.parse function to parse the response:

http://docs.telerik.com/aspnet-mvc/getting-started/custom-datasource#initial-setup

.Schema(schema => schema
    .Data("Data")
    .Total("Total")
    .Errors("Errors")
    .Parse(@<text>function (data) {
        // configure a parse function only if the response (data) must be
        // transformed in some way before data binding
        return data;
    }</text>)

http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-schema.parse

I hope this is helpful.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Semenov
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or