OData data source, load the page containing the newly added record
I have a grid being fed through an OData4 adapter. I have a custom dialog for creating and editing records. Once a record is added, I get a callback and need to refresh the grid loading the page that contains the newly created object. I can do the query to find the new record by id but that would load a single result. I want to load the full page with the new object at the top.
Thanks.
SIGN IN To post a reply.
2 Replies
EK
Edward Kagan
May 24, 2020 01:57 PM UTC
Been a few days. Can I get some advice, please?
VN
Vignesh Natarajan
Syncfusion Team
May 25, 2020 07:15 AM UTC
Hi Edward,
Thanks for contacting Syncfusion support.
Query: “I want to load the full page with the new object at the top.”
From your query we understand that you want to navigate to page where new record is inserted. We have prepared a ODataV4 sample where the Primary Key is autoincrement in database (odatav4 service). So every time new record is inserted, it will be inserted at the last position. So we have navigated to that last page using the OnActionBegin event and GotoPage method of Grid.
|
<SfGrid @ref="Grid" TValue="Order" AllowFiltering="true" AllowSorting="true" AllowPaging="true" Toolbar="@( new List<string> {"Add", "Edit","Delete","Update","Cancel" })">
<GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Menu"></GridFilterSettings>
<GridPageSettings PageSize="4"></GridPageSettings>
<GridEvents OnActionBegin="BeginHandler" TValue="Order"></GridEvents>
<GridEditSettings AllowEditing="true" AllowAdding="true" AllowDeleting="true"></GridEditSettings>
<SfDataManager Url="http://localhost:64956/odata/books" Adaptor="Adaptors.ODataV4Adaptor"></SfDataManager>
<GridColumns>
. . . . .. . .
</GridColumns>
</SfGrid>
@code{
SfGrid<Order> Grid { get; set; }
public async Task BeginHandler(ActionEventArgs<Order> Args)
{
if(Args.RequestType == Syncfusion.Blazor.Grids.Action.Save)
{
await Task.Delay(200); // wait till save action gets completed
double result = (double)(Grid.TotalItemCount + 1) / Grid.PageSettings.PageSize; //calculating the page where record is inserted
await Grid.GoToPage(Math.Ceiling(result)); // navigate to that page
}
}
}
|
Kindly download the sample from below
Below project consist of two parts. So kindly run ODataV4Service application first then run the BlazorApp.
If above solution does not resolve your query, kindly get back to us with following details.
- Share the details a out your OdataV4 services.
- Share video demonstration where the new record is inserted in your database.
- If possible try to reproduce the reported behavior in provided sample or share the issue reproducible sample.
Regards,
Vignesh Natarajan
SIGN IN To post a reply.
- 2 Replies
- 2 Participants
-
EK Edward Kagan
- May 22, 2020 07:24 PM UTC
- May 25, 2020 07:15 AM UTC