filters do not work in the grid Error: System.NullReferenceException: 'Object reference not set to an instance of an object.' dm.Where[0].Operator

Code cshtml.cs 
public ActionResult OnPostSetdataGridSafetynote([FromBody]DataManagerRequest dm)
        {
           var DataSource = _Repository.GetAll();
            var operation = new DataOperations();
            if (dm.Search != null && dm.Search.Count > 0)
            {
                DataSource = operation.PerformSearching(DataSource, dm.Search);  //Search
            }
            if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting
            {
                DataSource = operation.PerformSorting(DataSource, dm.Sorted);
            }
            if (dm.Where != null && dm.Where.Count > 0) //Filtering
            {
                DataSource = operation.PerformFiltering(DataSource, dm.Where, dm.Where[0].Operator);
            }
            int count = DataSource.Cast<GridDTO>().Count();
            if (dm.Skip != 0)
            {
                DataSource = operation.PerformSkip(DataSource, dm.Skip);//Paging
            }
            if (dm.Take != 0)
            {
                DataSource = operation.PerformTake(DataSource, dm.Take);
            }
            return dm.RequiresCounts ? new JsonResult(new { result = DataSource, count = count }) : new JsonResult(DataSource);

        }

Code Cshtml

<ejs-grid id="Grid" dataBound="dataBound" allowPaging="true" allowSorting="true" allowFiltering="true" toolbar="@(new List<string>() {"Search" })" load="onLoad">
                                <e-grid-filterSettings type="Menu" mode="OnEnter" showFilterBarStatus="true"></e-grid-filterSettings>
                                <e-data-manager url="grid?handler=Setdata" adaptor="UrlAdaptor"></e-data-manager>
                                <e-grid-columns>
                                    <e-grid-column field="id" headerText="ID" isPrimaryKey="true" textAlign="Right" width="120" visible="false"></e-grid-column>
                                    <e-grid-column field="title" headerText="title" textAlign="Left" width="200"></e-grid-column>
                                    <e-grid-column field="description" headerText="description" textAlign="Left"></e-grid-column>
                                    <e-grid-column field="created" headerText="created" width="150"></e-grid-column>
                                </e-grid-columns>
                            </ejs-grid>

Attachment: Error_en_Debug_8cd6d528.rar

3 Replies

HJ Hariharan J V Syncfusion Team August 23, 2018 12:12 PM UTC

Hi Patricio, 

Thanks for contacting Syncfusion support. 

We have tried to reproduce the reported issue from our side by creating a sample using the provided codes. But we were unsuccessful. The filtering performs fine in the Grid with URLAdaptor. Please download the working sample from the link below, 

 

If you are still facing the reported issue, please get back to us with the following details, 

  1. Share with us exact scenario/proper replication procedure.
  2. Share the codes you are using in the “dataBound” and “load” events.
  3. Share the screenshot of the contents you get in the “dm” object, when you are facing the error.

Please get back to us if you need further assistance. 

Regards, 
Hariharan 



PV Patricio Venegas B August 23, 2018 06:57 PM UTC

it was already resolved thanks


HJ Hariharan J V Syncfusion Team August 24, 2018 04:24 AM UTC

Hi Patricio, 

Thanks for your update. We are happy to hear that your problem has been resolved.
 
 
Regards,  
Hariharan 


Loader.
Up arrow icon