Hi there,
I have encountered this problem and can not fix the filter for these two columns.
If I use filter for these two columns: EnrolledNumber and WaitListNumber, I will get
Internet Server Error
Invalid Property or Field - 'EnrolledNumber' for type: Class
If I disabled both sortable and filter for these two columns, everything else will work fine.
How can I make the filter work and at the same time the program will not lag or become ridiculously slow?
The following is my code.
Model
EnrolledNumber = model.ClientClasses.Where(i => i.IsActive ==
true
).Count();
WaitListNumber = model.ClientClasses.Where(i => i.IsActive ==
false
).Count();
[Display(Name =
"Enrolled"
)]
public
int
EnrolledNumber {
get
;
set
; }
[Display(Name =
"WaitList"
)]
public
int
WaitListNumber {
get
;
set
; }
View
columns.Bound(i => i.EnrolledNumber).Width(90).Title(
"Enrolled"
);
columns.Bound(i => i.WaitListNumber).Width(90).Title(
"WaitList"
);
Controller
public
ActionResult Read_Classes([DataSourceRequest] DataSourceRequest request,
bool
isCurrent,
bool
isPending,
bool
isFinished)
{
IQueryable<Class> items = DbContext.Classes.Where(i => i.IsActive);
if
(!isPending)
items = items.Where(i => !i.Pending);
if
(!isFinished)
items = items.Where(i => !i.Finished);
if
(!isCurrent)
items = items.Where(i => i.Finished || i.Pending);
return
Json(items.ToDataSourceResult(request, i =>
new
ClassListViewModel(i)));
}
I also get
An exception of type 'System.ArgumentException' occurred in Kendo.Mvc.dll but was not handled in user code
in Visual Studio for first time
Thank you