bosskmk / pluto_grid

PlutoGrid is a dataGrid for flutter that can be controlled by the keyboard on desktop and web. Of course, it works well on Android and IOS.
https://pluto.weblaze.dev
MIT License
636 stars 290 forks source link

How to rows data refresh(update) with loader on click button #975

Closed IrfanHangingPanda closed 6 months ago

IrfanHangingPanda commented 7 months ago

Hello, How to PlutoGrid rows data update(refresh) with Loader on click button.

I want the rows data to be refreshed with loader when the refresh icon is clicked. Even if we remain on any pagination number, when the tab is refreshed, it shows us the data of pagination 1.

On refresh fetchData should call currentPage 1 await fetchData(currentPage, false, list);

Here the image refresh icon with data

Screenshot 2023-11-16 at 3 46 52 PM

Here the fetch function code ` Future fetch( PlutoLazyPaginationRequest request, ) async { currentPage = request.page; await fetchData(currentPage, false, list);

return PlutoLazyPaginationResponse(
  totalPage: (totalNumber / rowsPerPage).ceil(),
  rows: getRowsFromDbData(),
);

}`

Here the getRowsFromDbData code

List<PlutoRow> getRowsFromDbData() { return databaseData.map((row) { return PlutoRow( cells: { 'id': PlutoCell(value: row['id'].toString()), 'visitor_name': PlutoCell(value: row['visitor_name']), 'nvr_name': PlutoCell(value: row['nvr_name']), }, ); }).toList(); }

Plutogrid code

`PlutoGrid( key: _plutoGridKey, columns: columns, rows: databaseData.isNotEmpty ? getRowsFromDbData() : [], // columnGroups: columnGroups,

      onLoaded: (PlutoGridOnLoadedEvent event) {
        stateManager = event.stateManager;
        stateManager!.setShowColumnFilter(true);
        /// When the grid is finished loading, enable loading.
        stateManager!.setShowLoading(true);
      },
      onChanged: (PlutoGridOnChangedEvent event) {
        print(event);
      },
      rowColorCallback: (rowColorContext) {
        return Color(rowColorContext.rowIdx);
      },
      noRowsWidget: Center(
        child:
            Text('Data not found', style: TextStyle(color: Colors.white)),
      ),
      createFooter: (stateManager) {
        return PlutoLazyPagination(
          initialPage: currentPage,
          initialFetch: true,
          fetchWithSorting: true,
          fetchWithFiltering: true,
          fetch: fetch,
          stateManager: stateManager,
        );
      },
      configuration: PlutoGridConfiguration.dark(
          columnSize: PlutoGridColumnSizeConfig(
              autoSizeMode: PlutoAutoSizeMode.equal)),
    )`
github-actions[bot] commented 6 months ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 6 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.