DataGrid does not update after I filter on a field

I'm trying to refresh a DataGrid after I filter the data source using a text field and a button.

The data is provided by a StreamProvider.

Future<bool> getStreamData(context) async {
_patients = Provider.of<List<PatientModel>>(context);
_patients = _patients.where((patient) => patient.isTester == sett.areTesters).toList();
_patientsDataSource = PatientDataSource(_patients, _fireStoreDataBase);
_patientsDataSource.updateDataGridSource();

return true;
}

This is how it's called.

  ..
return FutureBuilder(
future: getStreamData(context),
builder: (BuildContext context, value) {

if (value.hasData) {
return SfDataGridTheme(
..

And I get the data in the DataGrid.



But when I filter, I call this function that updates the list of patients, but the datagrid is not refreshed.

filterByEmail(fieldValue)  {
_patients = _patients.where((patient) => patient.email!.toLowerCase().contains(fieldValue.toLowerCase())).toList();
_patientsDataSource = PatientDataSource(_patients, _fireStoreDataBase);
_patientsDataSource.buildDataGridRows();
_patientsDataSource.updateDataGridSource();
}



1 Reply

RS Renugadevi Sadagoban Syncfusion Team July 19, 2021 12:50 PM UTC

Hi Juan 
Thanks for contacting sycfusion support.  
  
Usually, DataGrid will be refreshed when you call notifyListeners method from DataGridSource class. It seems you have called the notifyListeners method in your application too. We couldn't find the exact reason "why the Datagrid is not refreshed" from your code snippets. We have prepared the following sample for updating the collection at runtime. It's working fine from our side.  
  
 
Please check the above sample at your end and let us know if we missed anything other than way of refreshing the datagrid. 
 
Regards, 
Renuga devi S 


Loader.
Up arrow icon