Filtering not working

Hello,

I used ejs grid and Excel filter settings but filtering is not working, nothing is happening when i change the filter. I tried another filter settings type and the result is same.
I think maybe there is a bug.

<ejs-grid id="grid" allow-paging="true" toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" })" allowFiltering="true">
    <e-grid-filterSettings type="Excel"></e-grid-filterSettings>
    <e-grid-editSettings allowAdding="true" allowDeleting="true" allowEditing="true" mode="Dialog" showDeleteConfirmDialog="true"></e-grid-editSettings>
    <e-data-manager url="@Url.Action("DataSource")"
                    updateUrl="@Url.Action("Update")"
                    insertUrl="@Url.Action("Insert")"
                    removeUrl="@Url.Action("Delete")"
                    adaptor="UrlAdaptor"></e-data-manager>
    <e-grid-columns>
        <e-grid-column field="AnimalBreedId" foreignKeyField="Id" foreignKeyValue="Title" dataSource="ViewBag.AnimalBreedList" width="130"></e-grid-column>
        <e-grid-column field="FoodTypeId" foreignKeyField="Id" foreignKeyValue="Title" dataSource="ViewBag.FoodTypeList" width="130"></e-grid-column>
    </e-grid-columns>
</ejs-grid>





3 Replies 1 reply marked as answer

SM Shalini Maragathavel Syncfusion Team February 1, 2021 11:20 AM UTC

Hi Alp, 

Thanks for contacting Syncfusion support.

Based on your query we suspect that you are facing an issue while perform filtering in the Grid. So, we have prepared a sample and tried to reproduce the issue but we did not face the mentioned issue at our end.

For your convenience we have attached the sample and please find the sample for your reference 

Sample : https://www.syncfusion.com/downloads/support/forum/162039/ze/UrlAdaptor-CRUD-NormatEdit481686229.zip

If you are still facing the issue, kindly share the following details that will be helpful for us to provide better solution.

1) Share the complete Grid rendering code. 
 
2)  If possible please replicate the issue in the attached sample.  

3)  Syncfusion Package version.  

Regards,
Shalini M. 



AL Alp February 1, 2021 03:17 PM UTC

Hello,

I am currently using Syncfusion.EJ2.AspNet.Core 18.4.0.39 version. 

  public ActionResult DataSource(DataManager dm)
        {
            var dataSource = AnimalBreedFoodTypeRepo.GetList();
            var count = dataSource.Count();
            return Json(new { result = dataSource, count = count });
        }

  public static List<JnAnimalBreedFoodType> GetList()
        {
            using (var db = new Context())
            {
                return db.JnAnimalBreedFoodType.ToList();
            }
        }

 public partial class JnAnimalBreedFoodType
    {
        public int Id { get; set; }
        public int AnimalBreedId { get; set; }
        public int FoodTypeId { get; set; }

        public virtual CtAnimalBreed AnimalBreed { get; set; }
        public virtual CtFoodType FoodType { get; set; }
    }


SM Shalini Maragathavel Syncfusion Team February 2, 2021 11:57 AM UTC

Hi Alp, 

Thanks for your update. 

We checked your code example and found that the filter query is not handled for the Grid in your controller side which is the cause of the issue. So, we need to handle the filter query in our server-side to perform the filtering action in the Grid. To resolve your issue we suggest you to handle the Grid actions as demonstrated in the below code snippet, 

HomeController.cs
 
public IActionResult UrlDatasourceChild([FromBody]DataManagerRequest dm) 
        { 
            IEnumerable DataSource = OrdersData.GetAllRecords(); 
            DataOperations 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); 
            } 
            var MergeListData = DataSource.Cast<object>().ToList(); 
            
            int count = DataSource.Cast<OrdersData>().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 ? Json(new { result = DataSource, count = count }) : Json(DataSource); 
        } 
 

Screenshot:





While using Urladaptor the request will be sent to server for every action like filtering, sorting, searching, CRUD in Grid. Based on query string we need to handle the actions in the controller page.  

Please find the  below sample for your reference. 


Let us know if you have any concerns. 

Regards, 
Shalini M. 


Marked as answer
Loader.
Up arrow icon