bindTo method
Ikat controller ke sourceId/collection — memuat kolom (jika ganti)
dan halaman pertama.
Implementation
Future<void> bindTo(String sourceId, String collection) async {
final changed = _boundSourceId != sourceId || _boundCollection != collection;
if (changed) {
_disposePagination();
_boundSourceId = sourceId;
_boundCollection = collection;
_ensurePagination(sourceId, collection);
}
final firstLoad = pagination!.isInitialLoad;
if (firstLoad || changed) {
loading = true;
notifyListeners();
}
try {
if (changed || columns.isEmpty) {
columns = await _repository.getColumns(sourceId, collection);
columnsTable = collection;
}
await pagination!.loadPage(0);
searchText = '';
sortColumn = null;
sortAscending = true;
loading = false;
notifyListeners();
} catch (error) {
loading = false;
lastError = 'Failed to load rows: $error';
notifyListeners();
}
}