Sorting and paging and filtering in child grid in url adaprter

I have this grid with url adapter in child gird. it seems like child grid's filtering and paging not working
below is code. i have added those take and skip bit its not working

@(Html.EJ().Grid<PurchasingCategoryViewModel>("purchasingItems")
                            .Datasource(datasource => datasource.Json((IEnumerable<PurchasingCategoryViewModel>
                        )Model)
                        .UpdateURL(@Url.Action("UpdatePurchasingCategory")).InsertURL(@Url.Action("CreatePurchasingCategory")).RemoveURL(@Url.Action("RemovePurchasingCategory"))
                        .Adaptor(AdaptorType.RemoteSaveAdaptor))
                        .EditSettings(edit => { edit.AllowAdding().AllowEditing().AllowEditOnDblClick(false).EditMode(EditMode.InlineForm).ShowConfirmDialog(true).TitleColumn("Code"); })
                        .ToolbarSettings(toolbar =>
                        {
                            if (CurrentUser.HasFullPageControl(Permission.Options))
                            {
                                toolbar.ShowToolbar().ToolbarItems(items =>
                                {
                                    items.AddTool(ToolBarItems.Add);
                                });
                            }
                        })
                        .AllowFiltering()
                        .AllowSorting()
                        .AllowPaging()
                        .AllowResizing()
                        .EnableHeaderHover()
                        .EnableRowHover()
                        .AllowSelection()
                           .PageSettings(builder => builder.PageSizeList(new List<int>
        { 50, 200, 500, 10000 }))
        .PageSettings(p => p.PageSize(50))
        .FilterSettings(filter => { filter.MaxFilterChoices(int.MaxValue); filter.FilterType(FilterType.Excel); })
        .Locale("en-GB")
        .Columns(col =>
        {
            col.Field(x => x.Id)
            .HeaderText("Id").Visible(false)
            .TextAlign(TextAlign.Left)
            .Add();
            col.Field(x => x.Code)
            .TextAlign(TextAlign.Left)
            .Add();
            col.Field(x => x.DateCreated)
       .TextAlign(TextAlign.Left)
       .Add();
            col.Field(x => x.CreatedByUser)
       .TextAlign(TextAlign.Left).Visible(false)
       .Add();
            col.Field(x => x.DateUpdated)
       .TextAlign(TextAlign.Left)
       .Add();
            col.Field(x => x.UpdatedByUser)
    .TextAlign(TextAlign.Left).Visible(false)
    .Add();
            col.HeaderText("Actions")
            .Template(CurrentUser.HasFullPageControl(Permission.StockRequirements) ? "<a rel='nofollow' href='javascript:void(0)' data-purchasingCategory-id='{{:Id}}' class='btn-black btn btn-xs edit-data purchasingCategory-update-button'>Edit</a> &nbsp <a rel='nofollow' href='javascript:void(0)' data-purchasingCategory-id='{{:Id}}' class='btn-black btn btn-xs edit-data purchasingCategory-delete-button'>Delete</a>" : "")
            .TextAlign(TextAlign.Center)
            .Width(120).
            Add();
        })
        .ClientSideEvents(events =>
        {
            events.ActionFailure("mrp.purchasingItems.purchasingCategoryActionFailure");
            events.ActionComplete("mrp.purchasingItems.purchasingCategoryActionComplete");
        })
        .ChildGrid<PurchasingItemViewModel>
        (child =>
        {
            child.Datasource(datasource => datasource.URL(@Url.Action("GetAllPurchasingItemsByCategory")).UpdateURL(@Url.Action("UpdatePurchasingItems")).InsertURL(@Url.Action("CreatePurchasingItems")).RemoveURL(@Url.Action("RemovePurchasingItems"))
            .Adaptor(AdaptorType.UrlAdaptor))
            .QueryString("Id").EditSettings(edit => { edit.AllowAdding().AllowEditing().AllowDeleting().AllowEditOnDblClick(false).EditMode(EditMode.InlineForm).ShowConfirmDialog(true).TitleColumn("Code"); })
            .ToolbarSettings(toolbar =>
            {
                if (CurrentUser.HasFullPageControl(Permission.Options))
                {
                    toolbar.ShowToolbar().ToolbarItems(items =>
                    {
                        items.AddTool(ToolBarItems.Add);
                    });
                }
            }).AllowFiltering()
                        .AllowSorting()
                        .AllowPaging(true)
                        .AllowSelection()
                           .PageSettings(builder => builder.PageSizeList(new List<int>
        { 50, 200, 500, 10000 }))
        .PageSettings(p => p.PageSize(50))
        .FilterSettings(filter => { filter.MaxFilterChoices(int.MaxValue); filter.FilterType(FilterType.Excel); })
            .CssClass("childGridBackgroundColor childGrid50PercentWidth")
            .AllowPaging(false)
            .Locale("en-GB")
            .Columns(col =>
            {
                col.Field(x => x.Id)
            .HeaderText("Id").Visible(false)
            .TextAlign(TextAlign.Left)
            .Add();
                col.Field(x => x.Code)
            .TextAlign(TextAlign.Left)
            .Add();
                col.Field(x => x.DateCreated)
        .TextAlign(TextAlign.Left)
        .Add();
                col.Field(x => x.CreatedByUser)
           .TextAlign(TextAlign.Left).Visible(false)
           .Add();
                col.Field(x => x.DateUpdated)
           .TextAlign(TextAlign.Left)
           .Add();
                col.Field(x => x.UpdatedByUser)
        .TextAlign(TextAlign.Left).Visible(false)
        .Add();
                col.HeaderText("Actions")
            .Template(CurrentUser.HasFullPageControl(Permission.StockRequirements) ? "<a rel='nofollow' href='javascript:void(0)' data-purchasingItems-id='{{:Id}}' class='btn-black btn btn-xs edit-data purchasingItems-update-button'>Edit</a>" +
            "&nbsp <a rel='nofollow' href='javascript:void(0)' data-purchasingItems-id='{{:Id}}' class='btn-black btn btn-xs edit-data purchasingItems-delete-button'>Delete</a>" : "")
            .TextAlign(TextAlign.Center)
            .Width(120).
            Add();
            }).ClientSideEvents(events =>
            {
                events.ActionComplete("mrp.purchasingItems.purchasingItemsActionComplete");
                events.ActionFailure("mrp.purchasingItems.purchasingCategoryActionFailure");
            });
        })
)


1 Reply 1 reply marked as answer

FS Farveen Sulthana Thameeztheen Basha Syncfusion Team May 3, 2021 03:37 PM UTC

Hi Sandip, 

Thanks for contacting Syncfusion Support. 

Query#:- I have this grid with url adapter in child gird. it seems like child grid's filtering and paging not working 
 
We have checked your reported problem by preparing sample but we are unable to reproduce the issue at our end(Filtering, Sorting and Paging actions works fine for child Grid). Refer to the sample Link:- 
 
Refer to the below KB link:- 
 
We suspect that the reported problem may occur when Count has not return properly after performing the data operations. Refer to the code below:- 

@(Html.EJ().Grid<object>("HierarchyGrid") 
                    .Datasource((IEnumerable<object>)ViewBag.data) 
                    .AllowSearching(true) 
                     
         }) 
                 .ChildGrid(child => 
                 { 
                     child.Datasource(datasource => datasource.URL("/Home/ChildData").        Adaptor(AdaptorType.UrlAdaptor)) 
                     .AllowFiltering()     
                     .QueryString("EmployeeID") 
                        .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); }) 
                         
                        .ClientSideEvents(eve => eve.Load("childLoad")) 
                         
                        .Columns(col => 
                        { 
                            .  .   . 
 
                        }) 
                 }) 
 
) 
 
Server end 
public JsonResult ChildData(DataManager dm) 
        { 
            if (order.Count() == 0) 
                BindDataSource(); 
            IEnumerable data = order; 
            DataOperations operation = new DataOperations(); 
            if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting 
            { 
                data = operation.PerformSorting(data, dm.Sorted); 
            } 
            if (dm.Where != null && dm.Where.Count > 0) //Filtering 
            { 
                data = operation.PerformWhereFilter(data, dm.Where, dm.Where[0].Operator); 
            } 
            if (dm.Search != null && dm.Search.Count > 0) //Searching 
            { 
                data = operation.PerformSearching(data, dm.Search); 
            } 
            var count = data.AsQueryable().Count(); 
            if (dm.Skip != 0) 
            { 
                data = operation.PerformSkip(data, dm.Skip); 
            } 
            if (dm.Take != 0) 
            { 
                data = operation.PerformTake(data, dm.Take); 
            } 
            return Json(new { result = data, count = count }); 
 
        } 



Screenshot:- 
While on Sorting:- 
 

On Filtering:- 
 


We need some more additional details to find the cause of the issue. Share us the following details. 

  1. Complete Grid code example(server end).
  2. Issue that you have faced while on performing Dataoperations. Share us the detailed Explanation.
  3. Share us the Screenshot of Network Tab details(whether it send Post on performing these actions).
  4. Product version details.
  5. Share Video Demo to demonstrate your issue.
  6. If possible replicate it in the above sample and revert us back.


Regards, 
Farveen sulthana T 


Marked as answer
Loader.
Up arrow icon