doonfrs / pluto_grid_plus

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
27 stars 28 forks source link

Added filterWidgetBuilder #59

Closed Software365-info closed 4 months ago

Software365-info commented 4 months ago

While trying to customize our filters with the filterWidget we ran into some problems:

I have deprecated the filterWidget in PlutoColumn and instead added filterWidgetBuilder

This gives the developer the option to add custom filters widgets to the PlutoColumns. Below some examples of this being used in a client test project.

image

TextField(
      decoration: IFMInputDecoration().copyWith(
        hintText: "contains".tr,
        // contentPadding: const EdgeInsets.all(8),
        hintStyle: const IFMTextStyle().copyWith(
          color: grey,
          fontSize: filterFontSize,
        ),
        alignLabelWithHint: true,
      ),
      style: const IFMTextStyle().copyWith(
        color: grey,
        fontSize: filterFontSize,
      ),
      onChanged: handleOnChanged,
      focusNode: focusNode,
      controller: controller,
      enabled: enabled,
    );

The below dropdown is generated from the data available in the column itself image

final list = stateManager.refRows.originalList
      .map((row) => (row.cells[field]?.value as String?) ?? "")
      .toSet()
      .toList();

DropdownMenu(
      expandedInsets: EdgeInsets.zero,
      hintText: "choose".tr,
      controller: controller,
      focusNode: focusNode,
      enabled: enabled,
      onSelected: (value) {
        handleOnChanged.call(value ?? "");
      },
      textStyle: const IFMTextStyle().copyWith(
        fontSize: filterFontSize,
      ),
      dropdownMenuEntries: [
        ...list.map(
          (e) => DropdownMenuEntry(
            value: e,
            label: e,
          ),
        ),
      ],
    );

These changes would allow each type of column to have a it's own unique filter when necessary (no working example for from-to yet) image

Software365-info commented 4 months ago

@doonfrs any info about when and if we can get this merged? :)

doonfrs commented 4 months ago

Merged, Thank you @Software365-info !