Search function not working in DataGrid

Hi!
I'm facing a serious problem. I have a CRUD-based application. I have multiple SfGrid in my application. The problem is the search is not working. 

Sell the following images - 
1.


2.

You can see the value exists in the grid but the search not working. Surprisingly if I disable just my code debugging, I get the following error - 



System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=Syncfusion.Blazor
  StackTrace:
   at Syncfusion.Blazor.Data.EnumerableOperation.PerformSearching(IEnumerable dataSource, List`1 searchFilter)
   at Syncfusion.Blazor.Data.BlazorAdaptor.DataOperationInvoke[T](IEnumerable DataSource, DataManagerRequest queries)
   at Syncfusion.Blazor.Data.BlazorAdaptor.<>c__DisplayClass4_0`1.<PerformDataOperation>b__0()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

  This exception was originally thrown at this call stack:
    Syncfusion.Blazor.Data.EnumerableOperation.PerformSearching(System.Collections.IEnumerable, System.Collections.Generic.List<Syncfusion.Blazor.Data.SearchFilter>)
    Syncfusion.Blazor.Data.BlazorAdaptor.DataOperationInvoke<T>(System.Collections.IEnumerable, Syncfusion.Blazor.DataManagerRequest)
    Syncfusion.Blazor.Data.BlazorAdaptor.PerformDataOperation.AnonymousMethod__0()
    System.Threading.Tasks.Task<TResult>.InnerInvoke()
    System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(System.Threading.Thread, System.Threading.ExecutionContext, System.Threading.ContextCallback, object)
    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

What seems to be the problem? 
Here is my Grid Code - 

<SfGrid DataSource="contactService.GetPeoples()"
        AllowSorting="true" AllowSelection="false"
        AllowPaging="true" Toolbar="@(new List<string> { "Search","Print"})">
    <GridColumns>
        <GridColumn Field="Name" AllowSearching="true" />
        <GridColumn Field="PhoneNumber" HeaderText="Phone Number" AllowSearching="true" />
        <GridColumn Field="Total" AllowSearching="false" />
        <GridColumn Field="Paid" AllowSearching="false" />
        <GridColumn Field="Due" AllowSearching="false" />
        <GridColumn HeaderText="Manage" AllowSearching="false">
            <Template>
                @{ var data = context as Contractor;}

                <SfButton Icon="e-icons e-delete" OnClick="@(()=>DeleteContractor(data.Id))" />
            </Template>
        </GridColumn>
    </GridColumns>
</SfGrid>

I'm using .NET 5, SF v18.4.0.49. Thanks.

13 Replies 1 reply marked as answer

RS Renjith Singh Rajendran Syncfusion Team March 29, 2021 12:01 PM UTC

Hi Mahmudul, 

Greetings from Syncfusion support. 

We tried reproducing the reported problem by creating a sample based on the shared codes. But searching works fine with the sample created from our side. We are attaching the sample for your reference, please download the sample from the link below, 

Please refer the above attached sample, and if you are still facing difficulties then the following details would be helpful for us to proceed further. 

  1. Share the sample which you have tried from your side. This would be helpful for us to validate the problem based on your scenario.
  2. Share the video demo showing the replication of the problem you are facing.
  3. Share the exact scenario or proper replication procedure.
  4. Or if possible, reproduce the problem with the attached sample and share with us for further analysis.

The provided information will help us analyze the problem, and provide you a solution as early as possible. 

Regards, 
Renjith R 


Marked as answer

SA socrates anibal rivera rivera March 20, 2022 12:31 AM UTC

Hello.

Taking the example in   https://www.syncfusion.com/downloads/support/directtrac/general/ze/ServerApp-767411222

I believe searchsettings is not working. I only modified the sample like this and search no longer works:

<SfGrid DataSource="contactService"

        AllowSorting="true" AllowSelection="false"

        AllowPaging="true" Toolbar="@(new List<string> { "Search","Print"})">

    <GridSearchSettings Fields="@( new string[] { "Name", "PhoneNumbre" } )"></GridSearchSettings>

    <GridColumns>

        <GridColumn Field="Name" />

        <GridColumn Field="PhoneNumber" HeaderText="Phone Number" />

        <GridColumn Field="Total" />

        <GridColumn Field="Paid" />

        <GridColumn Field="Due" />

        <GridColumn HeaderText="Manage" >

            <Template>

                @{ var data = context as Contractor;}


                <SfButton IconCss="e-icons e-delete" OnClick="@( () => DeleteContractor( data.PhoneNumber ) )" />

            </Template>

        </GridColumn>

    </GridColumns>

</SfGrid>

I would like to know why.

Secondly, I believe is missing a new feature (Find?) that works as excel search (any hope to get something like that in the near future?). Your search is more like an "or of filters" while excel search is also needed.

Thanks in advance.

Regards,

Sócrates A Rivera R

([email protected])



RS Renjith Singh Rajendran Syncfusion Team March 21, 2022 11:46 AM UTC

Hi Socrates, 
 
We checked your shared codes and we could see that you have specified wrong field name value in GridSearchSettings. Instead of PhoneNumber you have mentioned as PhoneNumbre. This has caused the reported problem. We suggest you to ensure to provide proper Field name values to achieve this requirement. 
 
Please refer the codes below, 
 
 
<GridSearchSettings Fields="@( new string[] { "Name", "PhoneNumber" } )"></GridSearchSettings> 
 
 
Query : Secondly, I believe is missing a new feature (Find?) that works as excel search (any hope to get something like that in the near future?). Your search is more like an "or of filters" while excel search is also needed. 
We suggest you to refer to the below documentation for the list of supported operators with our Grid searching functionality. By default Contains operator will be applied during search, you can change the default operator by setting the Operator property of GridSearchSettings. Please refer the below documentation for more details. 
 
Also we have inbuilt support for performing excel like filtering action in grid columns. We suggest you to refer to the below documentations for more details.  
 
Kindly refer the above suggestions and if we have misunderstood your requirement, then kindly share with us a detailed explanation of your requirement along with a video demo explaining your requirement for us to proceed further. 
 
Regards, 
Renjith R 



SA socrates anibal rivera rivera replied to Renjith Singh Rajendran March 27, 2022 05:48 AM UTC

Agree. My mistake. Numbre is incorrect. Now it works.

Thats all for the first question.

In to the second. I suggest you take a look at the search capacity of excel. That capacity I believe is also needed in your datagrid (I repeat your "search" is more like an "or of filters" not bad but the other "excel search" is also required).

Thanks in advance.

After your comments I will close the issue.

Thanks again.

Best regards,

Sócrates A Rivera R



RS Renjith Singh Rajendran Syncfusion Team March 28, 2022 11:02 AM UTC

Hi Sócrates, 
 
We need the following details to further analyze this requirement and further proceed on this scenario. Kindly get back to us with the following details for better assistance, 
 
  1. Share with us a video demo explaining your exact requirement with Grid searching based on Microsoft excel search.
  2. Share with us a pictorial representation explaining your exact requirement with grid searching.
 
Are you expecting external search method instead of performing search using toolbar? If so, then we have support to perform search action programmatically using inbuilt SearchAsync method. Please refer the below documentation for more information. 
 
If SearchAsync method does not suite your requirement, then kindly share with us the requested detail for further analyzing the feasibility of achieving your exact requirement. 
 
Regards, 
Renjith R 



SA socrates anibal rivera rivera replied to Renjith Singh Rajendran March 29, 2022 08:43 PM UTC

Hello.

A video is too complicated for me.

Just create a xcel sheet with tree cells, two equal and one unequal vales.

Goto menu search/search and look for the equal value (then go to the second equal value); now search/search for the third (unequal) value.

Do you see how different is of your "search"?

If you do something like that just call it Find (if you please).

Thanks again.

Regards,

Socates A Rivera R



RS Renjith Singh Rajendran Syncfusion Team March 30, 2022 11:32 AM UTC

Hi Socates,


We have prepared a video demo doing a find in Microsoft excel file. Could you please refer the below video and confirm us whether you are referring to this feature of Microsoft Excel?


Are you are expecting a dialog to be opened when click on search textbox in grid’s toolbar as like in Microsoft Excel?


If we have misunderstood your scenario kindly share with us a pictorial representation(screenshot or video) showing a step by step details about your requirement for us to proceed further.


Regards,

Renjith R


Attachment: excelsearch_77c55bb5.zip


SA socrates anibal rivera rivera replied to Renjith Singh Rajendran March 30, 2022 11:21 PM UTC

Hello.

Thanks for the quick answer.

That is the one. You can see that your search is different from this "Find" of excel.

I very much would like to see in your datagrid this excel feature (selecting according to current style: cell or row).

It is not required (but very welcome, so you can specify function: contains -default-, start with, etc.) to open a dialog, it coud be done very well with a text box and a dropdown (for the function).

Thank you very mch for the attention

Thanks in advance.

Regards,

Sócrates A Rivera R



RS Renjith Singh Rajendran Syncfusion Team March 31, 2022 12:03 PM UTC

Hi Sócrates,


Thanks for your update.


Query : it coud be done very well with a text box and a dropdown (for the function).

We suggest you to achieve this requirement by rendering custom toolbar item(a SfDropDownList) for selecting search Operator list dynamically. Based on the selection from the dropdown you can dynamically modify the default GridSearchSettings Operator property of Grid’s search. Please refer the codes below. We have also attached a sample in this ticket.


 

<SfGrid ... Toolbar="@(new List<Object>() { "Print","Search",new ItemModel() { Type = ItemType.Input, Align=ItemAlign.Right, Template = AditionalOps}})">

    <GridSearchSettings Fields="@( new string[] { "Name", "PhoneNumber" } )" Operator=@ddlVal></GridSearchSettings>

    ...

</SfGrid>

 

    private RenderFragment AditionalOps => @<div>

         <SfDropDownList Placeholder="Select a Operator" TItem="string" TValue="Operator" DataSource="@OperatorsList" @bind-Value="@ddlVal" Width="30">

            <DropDownListEvents TItem="string" TValue="Operator" ValueChange="ValueChange"></DropDownListEvents>

        </SfDropDownList>

    </div>

    ;

    //assign Syncfusion.Blazor.Operator enum value as Dropdown's data

    public string[] OperatorsList = Enum.GetNames(typeof(Operator));

    public Operator ddlVal { get; set; } = Operator.Contains;

 

    public void ValueChange(ChangeEventArgs<Operator,string> args)

    {

        ddlVal = args.Value;

    }

 


References :

https://blazor.syncfusion.com/documentation/datagrid/searching#search-operators

https://blazor.syncfusion.com/documentation/datagrid/tool-bar

https://blazor.syncfusion.com/documentation/dropdown-list/data-source#enum-data-binding


Please get back to us if you need further assistance.


Regards,

Renjith R


Attachment: ServerApp_e660de13.zip


SA socrates anibal rivera rivera replied to Renjith Singh Rajendran March 31, 2022 05:41 PM UTC

Hello.

Thanks again for the quick answer.

I believe we did not understand each other.

My suggestion of text box and dropdown is for the hipothetical find (the search of excel) I have been refering to.

Is there any posibility that you modify your datagrid up to include the"find" I like very much?

Thaks in advance.

Best regards,

Sócrates A Rivera R



RS Renjith Singh Rajendran Syncfusion Team April 1, 2022 02:46 PM UTC

Hi Sócrates,


We could see that you are referring to the find and go styled search in grid. We have logged a feature request task for this requirement “Provide support for find and highlight the searched text in DataGrid”. At the planning stage for every release cycle, we review all open features and identify features for implementation based on specific parameters including product vision and technological feasibility. It will be implemented in any of our upcoming releases. 


You can now track the current status of this feature request from the below feedback page. Please follow up on the below feedback for future updates regarding this feature.

https://www.syncfusion.com/feedback/23710/provide-support-for-find-and-highlight-the-searched-text-in-datagrid


Regards,

Renjith R




SA socrates anibal rivera rivera replied to Renjith Singh Rajendran April 1, 2022 09:00 PM UTC

Hello.

Thank you very much for your support

I expect to see soon this feature in your datagrid.

Meanwhile, thanks again.

This matter will be closed.

Regards,

Sócrates A Rivera R



RS Renjith Singh Rajendran Syncfusion Team April 4, 2022 06:57 AM UTC

Hi Sócrates,


Thanks for your update. Please follow up on the below feedback for future updates on this feature request.

https://www.syncfusion.com/feedback/23710/provide-support-for-find-and-highlight-the-searched-text-in-datagrid


Regards,

Renjith R


Loader.
Up arrow icon