I could be wrong, but I believe I am finding that an error is triggered when a SfGrid GridColumn is asked to filter on a column that may contain a few Null values. As a programmer, I understand why this might be an issue; after all, how should a filter interpret a Null value?
I am of course able to find ways around this issue, but it would help to know whether or not it is necessary to take those alternative steps.
Hi Rick,
Greetings from Syncfusion.
We have prepared a simple sample and performed filtering by placing null values in the DataGrid column. But we could not able to replicate the reported issue at our end. Kindly check the below attached sample and code snippet for your reference.
If you still face difficulties, then kindly share us the below details from your end.
The above requested detail will be very helpful for us to validate the reported issue at our end.
Regards,
Prathap S
Prathap, as always I appreciate your response. I have looked at the sample you sent. You are right, that sample performs well; even with the null values. I will look more closely at my solution to see the differences between what your sample expresses and what I have done. IMPORTANTLY THOUGH...
Prathap, I am now in my second day of not being able access my Syncfusion Tickets page. That is the only reason I posted my question about SfGrid filtering and Nulls in Synfusion's Forum; rather than how I always post questions to Syncfusion. This has to be rectified! If it helps you to know this, for the last few days, every time I click "View Tickets" in my Dashboard I am taken to a page which says "Oops".
I also posted a Forum message about this sudden lack-of-access issue and I (surprisingly) haven't received a response about it. Making use of the Tickets page is very important to me. I need to be able to access it!
Please let me know how this can be resolved as soon as possible.
Prathap, upon further exploration, the error I was hitting when filtering on Nulls triggered the following error inside Syncfusion's "SfDropDownBase.cs"...
System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=Syncfusion.Blazor.DropDowns
StackTrace:
at Syncfusion.Blazor.DropDowns.SfDropDownBase`1.Search(String inputValue, IEnumerable`1 items, String filterType, Boolean ignoreCase) in Syncfusion.Blazor.DropDowns\SfDropDownBase.cs:line 542
However, the good news is that I may have found what I'll call a compromised (but successful) workaround for the issue. To explain...
Instead of the example offered in https://blazorplayground.syncfusion.com/embed/BXVTCNMDJKgWLmsU?appbar=true&editor=true&result=true&errorlist=true&theme=bootstrap5, imagine the following sample Model declaration:
public class MyClass
{
public int ID { get; set; }
public string? Name { get; set; }
}
Now, with the above Model in mind, imagine that in my database table there are 3 records. In those records, the 'Name' field values happen to be...
Record 1: Name="Hello World"
Record 2: Name=""
Record 3: Name=Null
Given the above Model, when my filter is based on "Name", no error will occur in SfDropDownBase.cs when handling Records #1 and #2 above. However, the Syncfusion error I've listed will occur at Record #3.
After close study, my compromise workaround for this issue turns out to be based on my having altered MyClass in the following manner...
public class MyClass
{
public int ID { get; set; }
public string? Name { get; set; } = string.Empty
// Notice above that I have now supplied 'Name' with a default value.
}
Once I did the above, the problem went away.
Prathap, in retrospect I can now see what was the issue here and it makes sense. Though this is going to be a significant task, I am even willing to conform the rest of my code to that discovery. That said, if an SfGrid's filtering process requires me to provide a default value for every property in every Class/Model, then I would offer the following respectful suggestion...
Syncfusion may want to make the fact that this is a requirement something that is stated prominently and explicitly in the SfGrid's support pages. In other words, preferably, one should not have to infer such a thing from sample code. (If all of this is indeed explicitly expressed on those page's, I am sorry, but I missed it).
If you have any more feedback to provide on this... including the time-saving possibility of my only having to supply default values to Model properties of String datatype... please do not hesitate to let me know. Thank you.
Regarding the reported issue “where clicking "View Tickets" in your
Dashboard takes you to a page displaying "Oops,”" we have already
shared details on our support portal.
We're glad to hear that setting a default value for the Name property helped resolve the issue on your end. However, you mentioned encountering this error when filtering on nulls. We attempted to reproduce the issue but were unable to replicate it. To proceed with investigating the reported problem, we require some additional clarifications from your side. Please share the following details:
|
|
The requested details will be very helpful for us to validate the issue on our end and provide a solution as soon as possible.
Thank you for your response. To answer your questions...
Are you using the FilterTemplate with a DropDown component inside the grid column? If yes, could you please provide the relevant code?
I have not incorporated a FilterTemplate at all, and perhaps that is my mistake. After having received your latest response, I took a quick look at a FilterTemplate example available inside this URL...
https://blazor.syncfusion.com/demos/datagrid/filtering?theme=bootstrap5
If you recommend this, when I have time, I will try to see if my issue is solved if I implement a FilterTemplate in the way that it is suggested in the above page.
Can you confirm if the error occurs only with string properties, or are other data types also affected?
I only encountered this issue on string data types. However, to be clear, it is my understanding that the database I am working with on my current project only allows strings to be null. In other words, I apologize, but I am not currently able to test if nulls in other data types would be an issue.
I look forward to hearing back from you.
Thank you for your update.
Based on your input, it appears that no filter template was used on your side, and we confirm that the issue occurred without a filter template. However, we have tried to reproduce the issue but were unable to replicate it when filtering null values in a string column. Therefore, we kindly request that you provide us with reproducible sample with sample data. This will help us validate the issue and offer a resolution as soon as possible.We appreciate your understanding. Additionally, please confirm if you've encountered the same issue with other data types. We look forward to your response.
Hello Prathap. Respectfully, I am not sure I fully understand your latest email.
Unless I am misunderstanding, you seem to be confirming that, when you did not use a FilterTemplate, you also experienced what I had originally written to you about. Then you seem to go on to say that you were unable to replicate my issue.
I also think I was quite clear about the fact that I had only experienced the issue on string data types. Although, I should point out again that my current project's database is not designed to let me experiment on other data types, because the only data types the current project's database allows to be null are string (varchar) fields.
I am probably misreading what you wrote, but I will admit I am confused. No rush, but when you can clarify this I would appreciate it.
(By the way, if it helps you to know this, I have not yet had the opportunity to apply a FilterTemplate in the way you have suggested. That having been said, please rest assured that if I find that doing so alleviates my problem, I will be happy to implement your suggestion throughout the solution I am currently working on).
As always, I look forward to hearing from you.
To clarify, we suspect that you previously used a FilterTemplate and faced the issue. However, based on your last update, we acknowledge that you have not used a FilterTemplate and have encountered the issue without one, specifically with string data types. We couldn't replicate the issue on our end, which is why a reproducible sample with sample data would be beneficial for our investigation. We appreciate your understanding and look forward to resolving this.