0

The error that i have received when tried to sort the Kendo grid by clicking on the Customer ID column is: {"Invalid property or field - 'CustomerID' for type: OMS_CUSTOMER"}. What else is needed to bind the columns of grid, model view and model. Thanks

controller _read function:

            IQueryable<OMS_CUSTOMER> CustomerList = this.dbContext.OMS_CUSTOMERs;

            DataSourceResult result = CustomerList.ToDataSourceResult(request
                , ModelState
                , c => new CustomerViewModel
                {
                    CustomerID = c.OMS_CUSTOMER_ID,
                    CustomerName = c.CUSTOMERNAME
                });

            return Json(result);

View:

        @model IEnumerable<NCBA.ViewModels.CustomerViewModel>

        @(Html.Kendo().Grid<NCBA.ViewModels.CustomerViewModel>()
            .Name("grid-CustomerViewModel")
            .DataSource(dataSource => dataSource
                .Ajax()
                .Model(
                        model =>
                        {
                            model.Id(cust => cust.CustomerID);
                        }
                )
                .Create(create => create.Action("_Create", "Customer"))
                .Read(read => read.Action("_Read", "Customer"))
                .Update(update => update.Action("_Update", "Customer"))
                .Destroy(destroy => destroy.Action("_Delete", "Customer"))
            )
            .Columns(columns =>
            {
                columns.Bound(c => c.CustomerID);
                columns.Bound(c => c.CustomerName);
                columns.Command(commands =>
                {
                    commands.Edit();
                    commands.Destroy();
                }).Title("Commands").Width(200);
            })
            .ToolBar(toolbar => toolbar.Create())
            .Editable(editable => editable.Mode(GridEditMode.InLine))
            .Pageable()
            .Sortable()
        )
Waqar
  • 624
  • 1
  • 7
  • 20
  • http://stackoverflow.com/questions/16484417/how-to-use-kendo-ui-grid-with-todatasourceresult-iqueryablet-viewmodel-and – cah1r Oct 23 '14 at 07:08
  • Thanks Mateusz. Although i have gone through this one but the real answer for me was there in a comment by CodingWithSpike:- "No, Kendo won't do that by default, as it has no idea what AutoMapper is going to do. You might be able to alter the request object before the DB call, and change IsActiveText to IsActive, but it would be manual on your part." – Waqar Oct 23 '14 at 11:52

0 Answers0