Search code examples
flutterantdpluto-grid

how can I set filter menu config in pluto_grid as antd Table


image https://ant.design/components/table#table image how can I achieved this in pluto_grid

the first pic is what I did in web with antd

I reimplemented this table in flutter with pluto_grid as below, however don't know how to get this check filter menu on table header. cause no property to customize the filter


Solution

  • if you didn't resolve this yet, you can see https://github.com/bosskmk/pluto_grid/pull/739?

    So, you can use pluto_grid fork pluto_grid_plus. There is additional filterWidget property on PlutoColumn.

    You can add your widget, eg. PopupMenuButton. In onSelected I use someting like:

    onSelected: (String value) {
        stateManager.setFilterWithFilterRows(_getFilterRows(stateManager, issueColumn, issueColumn.defaultFilter, value));
    }
    

    and _getFilterRows:

    List<PlutoRow> _getFilterRows(PlutoGridStateManager? stateManager, PlutoColumn column, PlutoFilterType filterType, String filterValue) {
        List<PlutoRow> foundFilterRows =
        stateManager!.filterRowsByField(column.field);
    
        if (foundFilterRows.isEmpty) {
          return [
            ...stateManager.filterRows,
            FilterHelper.createFilterRow(
              columnField: column.field,
              filterType: filterType,
              filterValue: filterValue,
            ),
          ];
        }
    
        foundFilterRows.first.cells[FilterHelper.filterFieldValue]!.value =
            filterValue;
    
        return stateManager.filterRows;
      }