Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 84751

Filter gives System.ArgumentException when adding a column from Model that is .Count()

$
0
0

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")]
publicintEnrolledNumber { get; set; }
[Display(Name = "WaitList")]
publicintWaitListNumber { get; set; }

View

columns.Bound(i => i.EnrolledNumber).Width(90).Title("Enrolled");
columns.Bound(i => i.WaitListNumber).Width(90).Title("WaitList");

Controller

publicActionResult Read_Classes([DataSourceRequest] DataSourceRequest request, boolisCurrent, boolisPending, boolisFinished)
{
    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);
    returnJson(items.ToDataSourceResult(request, i => newClassListViewModel(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


Viewing all articles
Browse latest Browse all 84751

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>