Column PerName, PerNric is from Person Model
so the scripts should Person.PerName, Person.PerNric etc
when i change my html using raw html from Generated DatatableJS and change the column with the right column then the data is showing, but when i try to search using include column then the datatable will showing up with the error
Instance property 'Person.PerName' is not defined for type 'mrs.Models.Teacher'
Hi @ekondur i have this query in my repository
public IQueryable GetDataResult()
{
return _repository.GetDataResult().Include(p => p.Person);
}
And i use it in my controller
[HttpPost] public JsonResult GetDataResult(DataRequest request) { result = _repo.GetDataResult().ToDataResult(request);
return Json(result);
}
DataResult
to showing up this data in my views @(Html.JS().Datatable()
.Class("table table-hovered table-striped dataTable")
.Name("datatable")
.LengthMenu(new int[] { 5, 10, 25, 50, 100 }, true, "All Pages")
.FixedColumns(leftColumns: 0, rightColumns: 1)
.ColumnSearching(true, "form-control", SearchPosition.Header)
.Columns(cols =>
{
cols.Field(a => a.tch_Id).Class("w-175px").Orderable(false).Searchable(false).Title("Actions").Template("'<div class=\"btn-group\"> <a class=\"btn btn-success px-4 mx-1\" onclick=\"goEdit('+row.tch_Id+')\" href=javascript:void(0)><i class=\"las la-pen-alt fs-5\"> Edit <a class=\"btn btn-danger px-4\" onclick=showingPrompt(\"./teacher/Delete/'+row.tch_Id+'\") href=javascript:void(0)><i class=\"las la-trash\"> Delete
all data in my Teacher Model is showing up but all data in my include model is not
when i check in my html the datatables script is like this
columns: [{ -- | data: 'tch_Id', | name: 'tch_Id', | defaultContent: '', | orderable: false, | searchable: false, | className: 'w-175px', | visible: true, | width: '', | 'render': function(data, type, row, meta) { return 'Column PerName, PerNric is from Person Model so the scripts should Person.PerName, Person.PerNric etc
when i change my html using raw html from Generated DatatableJS and change the column with the right column then the data is showing, but when i try to search using include column then the datatable will showing up with the error Instance property 'Person.PerName' is not defined for type 'mrs.Models.Teacher'
Regards Nasrul