The remote Datasource returns data, but grid does not display it

Hello Support, I am just trying to implement the Grid control for my application in dotnet core 6 and I wrote the following in the razor view:

@section ControlsSection{
@Html.EJS().Grid("DisplacementSaGrid").DataSource(ds => ds.Url(@Url.Action("IndexDataSource", "RmdDisplacementSa")).Adaptor("UrlAdaptor")).AllowSorting().Columns(col => { col.Field("iso3").HeaderText("Country ISO3").Width("120").Add(); col.Field("cntryName").HeaderText("Country Name").Width("170").Add(); col.Field("year").HeaderText("Year").Width("130").Add(); }).AllowPaging().AllowFiltering().Toolbar(new List() { "Search" }).Render()
}

The IndexDataSource action returns data, but for some reason, the gridview does not render the data and says No records to display. Please find below the code for the controller action: 


 public IActionResult IndexDataSource(DataManagerRequest dm) { IEnumerable DataSource =_db.VwDisplacementSas; var operation = new DataOperations(); var str = new List

(); 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().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); } 


 Please help point me in the right direction on what I am missing. Thanks

5 Replies 1 reply marked as answer

PS Pavithra Subramaniyam Syncfusion Team April 19, 2022 12:59 PM UTC

Hi Adekunle,


Thanks for contacting Syncfusion support.


We have tried to reproduce the issue with .net6 core sample but the Grid is working fine at our side. Please refer to the below sample link for more information


https://www.syncfusion.com/downloads/support/directtrac/general/ze/GridUrlAdaptor1245795075


So could you share the below details that will be helpful for us to provide a better solution as early as possible?


  1. Share the screenshot of the response from the server
  2. Bind “actionFailure” event to the Grid and share the argument details if the event got triggered
  3. Share the Syncfusion package version
  4. Is there any script error?


We also discussed a similar scenario in the below thread. So, please have a look at this which may be related to your issue.


https://forumassist.syncfusion.com/172493


Regards,

Pavithra S



AD Adekunle April 29, 2022 08:08 AM UTC

Hello Support,

Thanks for your help so far. I have bound the onActionFailure and it catches no errors.


Please find below the response from the datasource:


[

    {

        "iso3": "AGO",

        "cntryName": "Angola",

        "year": 2009,

        "conflictStockDisplacement": null,

        "conflictNewDisplacements": null,

        "disasterNewDisplacements": 86000,

        "disasterStockDisplacement": null,

        "totalNewDisplacement": 86000,

        "totalDisplacement": 0

    },

    {

        "iso3": "AGO",

        "cntryName": "Angola",

        "year": 2010,

        "conflictStockDisplacement": null,

        "conflictNewDisplacements": null,

        "disasterNewDisplacements": 79000,

        "disasterStockDisplacement": null,

        "totalNewDisplacement": 79000,

        "totalDisplacement": 0

    },

    {

        "iso3": "AGO",

        "cntryName": "Angola",

        "year": 2011,

        "conflictStockDisplacement": null,

        "conflictNewDisplacements": null,

        "disasterNewDisplacements": 227000,

        "disasterStockDisplacement": null,

        "totalNewDisplacement": 227000,

        "totalDisplacement": 0

    },

    {

        "iso3": "AGO",

        "cntryName": "Angola",

        "year": 2012,

        "conflictStockDisplacement": null,

        "conflictNewDisplacements": null,

        "disasterNewDisplacements": 6400,

        "disasterStockDisplacement": null,

        "totalNewDisplacement": 6400,

        "totalDisplacement": 0

    },

    {

        "iso3": "AGO",

        "cntryName": "Angola",

        "year": 2013,

        "conflictStockDisplacement": null,

        "conflictNewDisplacements": null,

        "disasterNewDisplacements": 2500,

        "disasterStockDisplacement": null,

        "totalNewDisplacement": 2500,

        "totalDisplacement": 0

    },

    {

        "iso3": "AGO",

        "cntryName": "Angola",

        "year": 2015,

        "conflictStockDisplacement": null,

        "conflictNewDisplacements": null,

        "disasterNewDisplacements": 5600,

        "disasterStockDisplacement": null,

        "totalNewDisplacement": 5600,

        "totalDisplacement": 0

    },

    {

        "iso3": "AGO",

        "cntryName": "Angola",

        "year": 2016,

        "conflictStockDisplacement": null,

        "conflictNewDisplacements": null,

        "disasterNewDisplacements": 19000,

        "disasterStockDisplacement": null,

        "totalNewDisplacement": 19000,

        "totalDisplacement": 0

    },

    {

        "iso3": "AGO",

        "cntryName": "Angola",

        "year": 2017,

        "conflictStockDisplacement": null,

        "conflictNewDisplacements": null,

        "disasterNewDisplacements": 14000,

        "disasterStockDisplacement": null,

        "totalNewDisplacement": 14000,

        "totalDisplacement": 0

    }

]



PS Pavithra Subramaniyam Syncfusion Team May 2, 2022 01:50 PM UTC

Hi Adekunle,


Thanks for sharing the details.


For data binding with the “UrlAdaptor” the Grid expects the response as “result” and “count” pair. From your update, it seems only the JSON value is returned which might be the cause of the issue. For further validation, we need some more details to check why the “dm.RequiresCount?” condition failed in your server. So, could you please share the below details that will be helpful?


  1. Share the arguments passed to the server along with the request
  2. Share the “dm.RequiresCount” value in the server
  3. Share an issue reproducible sample if possible
  4. Share the Syncfusion package version


Regards,

Pavithra S


Marked as answer

AD Adekunle replied to Pavithra Subramaniyam May 3, 2022 09:12 AM UTC

Thanks a lot for your help, this was definitely the case. It works now



PS Pavithra Subramaniyam Syncfusion Team May 4, 2022 11:51 AM UTC

Hi Adekunle,


It is great to hear that the provided information helps you.


Please get back to us if you need further assistance.


Regards,

Pavithra S


Loader.
Up arrow icon