SfGrid AllowGrouping on UrlAdaptor getting Server exception: 404 Not found (Blazor 18.1.56)

Hi I am getting Server exception: 404 Not found when I try to group SfGrid via UrlAdaptor

Razor
<SfGrid TValue="Order" AllowPaging="true" AllowGrouping="true">
    <SfDataManager Url="/api/values" Adaptor="Adaptors.UrlAdaptor"></SfDataManager>
    <GridEvents TValue="Order" OnActionFailure="@ActionFailure"></GridEvents>
    <GridPageSettings PageSize="100"></GridPageSettings>
    <GridColumns>
        <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Right" Width="120"></GridColumn>
        <GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="150"></GridColumn>
        <GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" Format="d" Type="ColumnType.Date" TextAlign="TextAlign.Right" Width="130"></GridColumn>
        <GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn>
    </GridColumns>
</SfGrid>

Code
// POST api/<ValuesController>
        [HttpPost]
        public object Post([FromBody] DataManagerRequest dm)
        {
            IEnumerable<Order> DataSource = BlazorAppServer1.Data.TestData.GetData();
 
            DataResult DataObject = new DataResult();
 
            if (dm.Search != null && dm.Search.Count > 0)
            {
                // Searching
                DataSource = DataOperations.PerformSearching(DataSource, dm.Search);
            }
            if (dm.Sorted != null && dm.Sorted.Count > 0)
            {
                // Sorting
                DataSource = DataOperations.PerformSorting(DataSource, dm.Sorted);
            }
            if (dm.Where != null && dm.Where.Count > 0)
            {
                // Filtering
                DataSource = DataOperations.PerformFiltering(DataSource, dm.Where, dm.Where[0].Operator);
            }
            int count = DataSource.Cast<Order>().Count();
            if (dm.Skip != 0)
            {
                //Paging
                DataSource = DataOperations.PerformSkip(DataSource, dm.Skip);
            }
            if (dm.Take != 0)
            {
                DataSource = DataOperations.PerformTake(DataSource, dm.Take);
            }
 
            if (dm.Group != null)
            {
                IEnumerable ResultData = Enumerable.Empty<Order>();
 
                foreach (var group in dm.Group)
                {
                    ResultData = DataUtil.Group<Order>(DataSource, group, dm.Aggregates, 0, dm.GroupByFormatter);
                }
                DataObject.Result = ResultData;
                DataObject.Count = count;
                return dm.RequiresCounts ? DataObject : (object)DataSource;
            }
 
            return dm.RequiresCounts ? new Syncfusion.Blazor.Data.DataResult() { Result = DataSource, Count = count } : (object)DataSource;
        }

Startup added
services.AddControllers().AddNewtonsoftJson(options =>
            {
                options.SerializerSettings.ContractResolver = new DefaultContractResolver();
            });




Attachment: BlazorAppServer1_5c398b06.rar

3 Replies 1 reply marked as answer

VN Vignesh Natarajan Syncfusion Team June 11, 2020 01:18 PM UTC

Hi Ashimaz,  

Thanks for contacting Syncfusion support.  

Query: “Hi I am getting Server exception: 404 Not found when I try to group SfGrid via UrlAdaptor 

From your query we understand that you are facing issue 404 error while binding data to Grid from WebAPI service. To validate the reported issue at our end we have prepared a sample using your code example. We are not able to reproduce the reported issue at our end. Kindly download the sample from below  


Note: From your code example we found that you are trying to group the data in Post method (In Controller) of UrlAdaptor. In Url Adaptor we will perform data operations like filtering, searching, sorting, paging in controller side and Grouping will be done at our source level. So kindly remove the below highlighted / commented codes to render the grid with grouping.  

public object Post([FromBody]DataManagerRequest dm) 
       { 
. . . .. . .  
           //if (dm.Group != null) 
           //{ 
           //    IEnumerable ResultData = Enumerable.Empty<Orders>(); 
 
           //    foreach (var group in dm.Group) 
           //    { 
           //        ResultData = DataUtil.Group<Orders>(DataSource, group, dm.Aggregates, 0, dm.GroupByFormatter); 
           //    } 
           //    DataObject.Result = ResultData; 
           //    DataObject.Count = count; 
           //    return dm.RequiresCounts ? DataObject : (object)DataSource; 
           //}            
. . . . .  
       } 


After referring the sample, if you are still facing the issue. Kindly share the following details.  

  1. Share the details about the error in OnActionFailure event.
  2. Are you facing any script error in console. If yes share the details about the issue.
  3. Are you facing the issue only while trying to Grid the column or during the initial rendering.
  4. Share you Syncfusion Nuget package.
  5. Try to reproduce the reported issue in provided sample and revert back to us.

Above requested details will be helpful for us to validate the reported issue at our end and provide solution as soon as possible.  

Regards, 
Vignesh Natarajan 


Marked as answer

AS ashimaz June 11, 2020 04:58 PM UTC

Thank you, issue resolved by removing the highlighted code.

FYI, This code was added as per following
https://www.syncfusion.com/forums/153319/blazor-grid-grouping-error-when-using-sfdatamanager-adaptors-iqueryable-18-1-44



VN Vignesh Natarajan Syncfusion Team June 12, 2020 05:26 AM UTC

Hi Ashimaz,  

Thanks for the update. 

We are glad to hear that you have resolve your query using our solution.  

Grouping solution provided in the Forum 153319 is for Custom Adaptor (CustomBinding) in Grid. 

Kindly get back to us if you have further queries.  

Regards, 
Vignesh Natarajan 


Loader.
Up arrow icon