Hi, I want to ask a question about the add record button in ASP.NET MVC Grid Popup Editing when I click on the button, it links to a page with this "{"Data":[],"Total":0,"AggregateResults":null,"Errors":null}".
1 Answer, 1 is accepted
0
Alexander
Telerik team
answered on 19 Sep 2023, 08:55 AM
Hi Tram,
Thank you for reaching out. It is great to have you here.
Seeing that this is your first thread please allow me to provide a more comprehensive explanation in regard to the exhibited behavior.
Generally, the Telerik UI for ASP.NET Core Grid component is composed of a DataSource mediator which establishes a bridge between the client-side and server layers upon: Edition, Filtering, Sorting, Paging, and Aggregation.
Provided if server-side operations are enabled. In addition to this, the DataSource provides a variety of binding mechanisms that could be incorporated.
In the context of the Grid Popup Editing scenario you currently are describing, the Grid uses Ajax Binding. When configured for Ajax Binding, the following aspects need to be taken into account:
A parameter of type "Kendo.Mvc.UI.DataSourceRequest" needs to be added to the action. It will contain the current Grid request information.
The parameter needs to be decorated through the "Kendo.Mvc.UI.DataSourceRequestAttribute". This is required, as the attribute will populate the DataSourceRequest object from the posted data.
The ".ToDataSourceResult()" extension method needs to be used in order to convert the data to a DataSourceResult object.
This is outlined in steps 6 to 8 in the Ajax Binding documentation. The ToDataSourceResult represents the following abstraction that is returned by the remote endpoint:
publicclassDataSourceResult
{
///<summary>/// The data collection.///</summary>public IEnumerable Data { get; set; }
///<summary>/// The total number of data entries.///</summary>publicint Total { get; set; }
///<summary>/// The result of the data aggregation.///</summary>public IEnumerable<AggregateResult> AggregateResults { get; set; }
///<summary>/// A list of errors that occurred during the creation of the data result.///</summary>publicobject Errors { get; set; }
}
From which the described behavior occurs. A more live-action scenario where this can be observed is available within the following demo:
Grid PopUp Editing (Demo) - open the "View Source" tab to observe the Grid's configuration and controllers.
Would you please confirm whether you have set up an identical scenario as the abovementioned? The described behavior is indeed rather unorthodox as upon creation, the metainformation of the DataSourceRequest needs to be supplemented.
Would it be possible for you to send the currently established Grid configuration, so that I could troubleshoot the behavior further? I would greatly appreciate it.
I look forward to your reply.
Kind Regards,
Alexander
Progress Telerik
Stay tuned by visiting our public roadmap and feedback portal pages. If you're new to the Telerik family, be sure to check out our getting started resources, as well as the onlyREPL playground for creating, saving, running, and sharing server-side code.