how can i use data from api to gridview with search filter ?

how can i use data from api to gridview with search filter  without fresh mvvm?




2 Replies

KK Karthikraja Kalaimani Syncfusion Team August 24, 2021 01:34 PM UTC

Hi Saber, 

Thank you for contacting Syncfusion support. 

Currently, we are validating your requirement. We will validate and update the further details on or before 26th August 2021. We appreciate your patience until then. 

Regards,
Karthik Raja


KK Karthikraja Kalaimani Syncfusion Team August 26, 2021 05:15 PM UTC

Hi Sabeer, 

Thanks for your patience. 

We have prepared a sample for your requirement to load the data from API to SfDataGrid. In that sample, we used Refit to fetch the data from the server and loaded the data to SfDatagrid asynchronously. So you've got to wait a few seconds to get data from the server. Before launching the app, make sure that you have to allow an internet connection.

Code snippet :
private async void getData() 
{ 
            var url = RestService.For<RefitApi>("http://makeup-api.herokuapp.com"); 
            var orderInfo = await url.GetCompanyAsync("maybelline"); 
            ObservableCollection<OrderInfo> records = JsonConvert.DeserializeObject<ObservableCollection<OrderInfo>>(orderInfo); 
            sfGrid.ItemsSource = records; 
            sfGrid.ColumnSizer = ColumnSizer.Star; 
            sfGrid.AllowEditing = true; 
            sfGrid.NavigationMode = NavigationMode.Cell; 
            sfGrid.SelectionMode = Syncfusion.SfDataGrid.XForms.SelectionMode.Single; 
 } 

public interface RefitApi 
{ 
        [Get("/api/v1/products.json?brand={symbol}")] 
        Task<string> GetCompanyAsync(string symbol); 
} 

Sample link : https://www.syncfusion.com/downloads/support/directtrac/general/ze/DataGrid_Demo-501673709

Please refer to the below UG link to add filtering to SfDataGrid. 

https://help.syncfusion.com/xamarin/datagrid/filtering


Regards,
Karthik Raja

Loader.
Up arrow icon