How to use the CamelCase formatting for a column

2 posts, 0 answers
  1. Semenov
    Semenov avatar
    1 posts
    Member since:
    Jun 2016

    Posted 18 Sep Link to this post

    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}

  2. Stefan
    Admin
    Stefan avatar
    1137 posts

    Posted 21 Sep Link to this post

    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.
Back to Top