У меня проблема с чтением данных для сетки кендо. Контроллер выдает исключение «Не удается найти общедоступное свойство примитивного типа для сортировки».Сортировка сетки Kendo со сложными объектами
ViewModel
public class PatientModel : IMapFrom<Patient>, IHaveCustomMappings
{
public int? Id { get; set; }
public PersonalDataModel PersonalDataModel { get; set; }
}
Контроллер
public ActionResult EditingPopup_Read([DataSourceRequest] DataSourceRequest request)
{
var source = repository.All<PatientModel>();
var patients = repository.All<PatientModel>().ToDataSourceResult(request);
return Json(patients,JsonRequestBehavior.AllowGet);
}
Посмотреть
@(Html.Kendo().Grid<DentalSoft.Data.Contracts.Patientes.PatientModel>()
.Name("PatientsGrid")
.Columns(columns =>
{
columns.Bound(p => p.PersonalDataModel.FirstName).Filterable(ftb => ftb.Cell(cell => cell.ShowOperators(false)));
columns.Bound(p => p.PersonalDataModel.SecondName).Filterable(ftb => ftb.Cell(cell => cell.ShowOperators(false)));
columns.Bound(p => p.PersonalDataModel.LastName).Filterable(ftb => ftb.Cell(cell => cell.ShowOperators(false)));
columns.Bound(p => p.PersonalDataModel.TelephoneNumber).Filterable(ftb => ftb.Cell(cell => cell.ShowOperators(false)));
columns.Bound(p => p.PersonalDataModel.HealthStatus).Filterable(ftb => ftb.Cell(cell => cell.ShowOperators(false))).Width(200);
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(250);
})
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("PatientModel"))
.ToolBar(toolbar => toolbar.Create())
.Scrollable()
.Sortable()
.Filterable(ftb => ftb.Mode(GridFilterMode.Row))
.HtmlAttributes(new { @class = "patients-grid" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Model(model => model.Id(p => p.Id))
.Create(create => create.Action("EditingPopup_Create", "Grid"))
.Read(read => read.Action("EditingPopup_Read", "Grid"))
.Update(update => update.Action("EditingPopup_Update", "Grid"))
.Destroy(destroy => destroy.Action("EditingPopup_Destroy", "Grid"))
)
.Selectable()
)
ViewModel будет имеет более 3,4 сложных объекта.