I have integrated NonFactors Grid in my Mvc5 application. Its filtering not working on inner class propery name however it works fine on its own properties. I have one class which is User
and this contains School
object onto it. This School
class a property
as Name
and I bind it to model as below
columns.Add(model => model.School.Name).Titled("School Name");
columns.Add(model => model.UserName).Titled("User Name");
When I apply a filter on User Name
it works perfectly fine but same is not working on School Name
. Its giving error in _Grid.cshtml
saying Object reference not set to an instance of an object.
'
Please refer below.
Can you please guide how to fix it? Thank You!
Adding null check on column value solved the problem.
columns.Add(model => model.School == null ? null : model.School.Name).Titled("School Name").Filterable(true);