We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Grid filtering causes null object error

I'm running into a strange situation with one of my grids. When I apply a filter to the first column (a string), the PerformFiltering method throws an "Object reference not set to an instance of an object" error. The strange part about this is that I have another grid that is set up almost exactly like this one and it is not throwing this error. Both are using URLAdaptor, both have mixed-type data (strings and decimals).

The Where[0] object in the grid that works is:

Where Count = 1 System.Collections.Generic.List<Syncfusion.EJ2.Base.WhereFilter>
[0] {Syncfusion.EJ2.Base.WhereFilter} Syncfusion.EJ2.Base.WhereFilter
Condition "and" string
Field null string
IgnoreCase false bool
IsComplex true bool
Operator null string
predicates Count = 1 System.Collections.Generic.List<Syncfusion.EJ2.Base.WhereFilter>
[0] {Syncfusion.EJ2.Base.WhereFilter} Syncfusion.EJ2.Base.WhereFilter
Condition null string
Field "SKU" string
IgnoreCase true bool
IsComplex false bool
Operator "startswith" string
predicates null System.Collections.Generic.List<Syncfusion.EJ2.Base.WhereFilter>
value "FBA_" object {string}
value null object


The Where[0] object for the one that doesn't work is:

Where Count = 1 System.Collections.Generic.List<Syncfusion.EJ2.Base.WhereFilter>
[0] {Syncfusion.EJ2.Base.WhereFilter} Syncfusion.EJ2.Base.WhereFilter
Condition "and" string
Field null string
IgnoreCase false bool
IsComplex true bool
Operator null string
predicates Count = 1 System.Collections.Generic.List<Syncfusion.EJ2.Base.WhereFilter>
[0] {Syncfusion.EJ2.Base.WhereFilter} Syncfusion.EJ2.Base.WhereFilter
Condition null string
Field "SKU" string
IgnoreCase true bool
IsComplex false bool
Operator "equal" string
predicates null System.Collections.Generic.List<Syncfusion.EJ2.Base.WhereFilter>
value "FBA_" object {string}
value null object

The declaration of the grids is nearly identical, aside from the name and number of columns. All options are set the same. The data for the grids is also nearly identical, except for the obvious.

SKU in both grids is a string. The default for string columns is "startswith"; the default for numbers is "equal".
  1. Why would "equal" be used for filtering a string column when I haven't mentioned anywhere that I want to use "equal"?
  2. Why is this even throwing an error? I thought it might be the data that has null values it doesn't like. I have verified this is not the case.
Any light you could shed on this problem is appreciated.

3 Replies

SS Seeni Sakthi Kumar Seeni Raj Syncfusion Team December 19, 2019 10:00 AM UTC

Hi Kevin, 

Our Grid has “startswith” operator in the string Column and “equal” operator in the number column. It is default behavior. We have tried to your query in the our Grid component with provided the information. But it is unsuccessful. We have created a sample with your query and share that sample for your reference. 


Still facing the same problem in your end. Could you please share the below details to us it will help to validate further. 

  1. Reproduce issue in the above sample.
  2. Share Essential Studio version.
  3. Is possible to share Grid dataSource in JSON format?
  4. Controller code example example with Index or view page of the Grid.

Regards, 
Seeni Sakthi Kumar S 



RC Roger Criebaum December 20, 2019 05:02 PM UTC

I was able to get your sample to work. From what I could tell, it all came down to (possibly) some null values in the data I was filtering. However, your sample is using .NET Core; mine is using .NET Standard 4.6.1 and MVC 5. When I applied the fixes and code that worked with my project, it still didn't work.

I've attached a sample project that demonstrates the problem. Note that because of file size restrictions, only the core of the solution is provided...no other libraries and packages. I'm using the latest 17.4.0.39 version. I built this application based on the "Grid: Getting Started" section of the documentation.

In the Index.cshtml, you'll see both an HTML grid definition and a (commented) JS grid. The JS grid does not get created--there is some kind of error. The HTML grid renders correctly. In the SKU search, enter "ONS_". This should throw an "Object reference..." error.

Attachment: GridTest_1769fe68.zip


SS Seeni Sakthi Kumar Seeni Raj Syncfusion Team December 23, 2019 11:33 AM UTC

Hi Kevin, 

We couldn’t see you reported problem with the provided demo and it has client end code alone not backend (Doesn’t defined UrlAdaptor data service in server-side). Now, we have created a sample with your requirement which is used the backend in ASP .Net MVC. Please refer to the below sample for your reference. 


Could you please reproduce the reported problem in the above sample it will help to validated further. 

Regards, 
Seeni Sakthi Kumar S 


Loader.
Live Chat Icon For mobile
Up arrow icon