SFPaging in Data grid having grouping

Hi ,
the below is my requirement & present Grid functionality i am having:

Existing grid functionality: Grouping  the fetched records based on an ID.

Requirement: 
1. Need to call API for every page click and get the fresh records to display for that particular page itself, when when clicked on another page again API calling and need to display the fetch records in that particular page.
2. Need to display the records along with the grouped records in a page.

Clear explanation :
The issue that i am facing is i am using OnDemandPaging, for initial grid load and data showing is getting right, but my requirement is when i click on the next/2 button i need to call the API again and get the records that need ti be displayed on the 2nd page, and then want to display those records on the 2nd page, and so on for remaining pages also(on page click calling api & getting the data that needed to be displayed on the page). How could i acquire this functionality with SF paging.

PFD for reference



Attachment: New_DOCX_Document_9d60f264.zip

4 Replies

PK Pradeep Kumar Balakrishnan Syncfusion Team May 27, 2020 11:08 AM UTC

Hi Codework, 
 
Thank you for contacting Syncfusion support. 
 
We have checked your requirement “Need to fetch new set of records for pagination using API service in Xamarin forms”.  We have prepared the sample for this requirement and found an issue that DataGrid is not refreshed based on the current page records. DataGrid showing first page records after navigating to second page and showing second page records after navigating to third page and so on. Are you facing this issue and this issue happening only when DataGrid has grouping. We have attached the prepared sample for your reference in the following link. 
 
 
Currently, we are validating to resolve this issue. We will validate and update further detail by May 29,2020. We appreciate your patience until then. 
 
In the meantime please check the attached sample and let us know are you facing the same issue and prepared sample meets you are requirement or not. 
 
Regards, 
Pradeep Kumar B 



CO Codework May 27, 2020 11:46 AM UTC

Thanks you for giving reply, but this is not my requirement.

My requirement is the 1st time i will call the API and load the data in 1st page (that is fine), now when i click the 2nd page i will call the API again to get the data that needed to be displayed in 2nd page & after fetching the records i want the new list to get displayed in 2nd page. similarly when i click on 1st page again API calling will be done and the new records will be fetched that needed to be displayed in the 1st page and i want those to be displayed in 1st page.


CO Codework May 28, 2020 12:29 PM UTC

URGENT REPLY NEEDED

Can you please tell me is any way to unload the grid and load it again at any point in the code.
I need the GridLoaded event to fire by loading the grid again in the page, dynamically from the code 


KK Karthikraja Kalaimani Syncfusion Team May 28, 2020 02:22 PM UTC

Hi CodeWork,

Regarding “Fresh data should be shown in Current page”

You can call the ResetCache method on OnDemandLoading event. This will not allow to load previous data. So, whenever you navigate to another page the new data will only shown in the current page. Please refer the below code snippet for calling ResetCache method.

Code snippet :

 
using Syncfusion.Data;

private
async void dataPager_OnDemandLoading(object sender, Syncfusion.SfDataGrid.XForms.DataPager.OnDemandLoadingEventArgs e) 
{
(dataPager.PagedSource
as PagedCollectionView).ResetCache();
}
 

UG link : https://help.syncfusion.com/xamarin/datagrid/paging#ondemandpaging

Regarding “I need the GridLoaded event to fire by loading the grid again in the page

Your requirement can be achieved by unsubscribe the GridLoaded event and remove the SfDataGrid from its parent and again add the SfDataGrid as a child to previous parent and again subscribe the GridLoaded event and finally forcelayout the SfDataGrid . For more details please refer the below code snippet.

Code snippet,

 
            stack.Children.RemoveAt(1); 
            dataGrid.GridLoaded -= DataGrid_GridLoaded; 
            dataGrid.GridLoaded += DataGrid_GridLoaded; 
            stack.Children.Insert(1, dataGrid); 
            dataGrid.ForceLayout(); 


Regards,
Karthik Raja 


Loader.
Up arrow icon