pluto_grid icon indicating copy to clipboard operation
pluto_grid copied to clipboard

Make PlutoColumnType extendable to allow for custom column types

Open cthurston opened this issue 4 years ago • 3 comments

My immediate inclination was to create my own custom column types, for example uuid, bool, or multi-select. However, the way that the column type is implemented doesn't seem to be extendable.

cthurston avatar Jul 21 '21 19:07 cthurston

I agree with @cthurston. I will like to customize my column to any widget, like an image. Not just "Text, number, date ......".

afesohromeo avatar Dec 18 '21 15:12 afesohromeo

@afesohromeo I also agree that it is necessary to add other types to PlutoGrid other than text, number, date, etc.

For widgets such as images, you can add a text type column to set the value as an image address and have the renderer output an image instead of text.

I would appreciate it if you could tell me a little more about the situation in which an additional part is needed in the above situation.

bosskmk avatar Dec 24 '21 02:12 bosskmk

Another example is select columns. If you have an usual pair of key + corresponding labels, it could be great to have something more versatile for this scenarios, like:

  /// Provides a selection list and sets it as a selection column.
  factory PlutoColumnType.select(
    Map<dynamic, String>? items, {  // 👈🏻 Change List<dynamic> to this Map to allow to use any type
    dynamic defaultValue = '',
    bool enableColumnFilter = false,
  }) {
  ...

henry2man avatar Jan 03 '22 07:01 henry2man

My actual need is to have an autocomplete column (values loaded from remote serveur with search filter)

The PlutoColumnTypeSelect has a "static list" and is not very usefull for editing "fast" in the grid

I think i will create a custom column type, with a specific renderer ( rendering a text if not editing, and an autocomplete if cell is currently in edit mode ) But i don't known if i can trigger the onChanged of the grid...

bdemeure avatar Dec 02 '22 09:12 bdemeure

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

github-actions[bot] avatar Jan 01 '23 11:01 github-actions[bot]

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

github-actions[bot] avatar Jan 18 '23 11:01 github-actions[bot]

Do we have any plans for support this?

henry2man avatar May 20 '23 06:05 henry2man

Any update on this?

niltonvasques avatar Jun 02 '23 15:06 niltonvasques

@afesohromeo I also agree that it is necessary to add other types to PlutoGrid other than text, number, date, etc. For widgets such as images, you can add a text type column to set the value as an image address and have the renderer output an image instead of text. I would appreciate it if you could tell me a little more about the situation in which an additional part is needed in the above situation.

how to do it? I cannot find any documentation to render image in cell

Add this code : renderer: (rendererContext) { final String imageURL = rendererContext.cell.value as String; return Image.network(imageURL); },

design2023 avatar Jul 30 '23 04:07 design2023

what about this? is there an option to show key+description?

PY-Account avatar Feb 29 '24 21:02 PY-Account

Another example is select columns. If you have an usual pair of key + corresponding labels, it could be great to have something more versatile for this scenarios, like:

  /// Provides a selection list and sets it as a selection column.
  factory PlutoColumnType.select(
    Map<dynamic, String>? items, {  // 👈🏻 Change List<dynamic> to this Map to allow to use any type
    dynamic defaultValue = '',
    bool enableColumnFilter = false,
  }) {
  ...

did you found some solution for this?

PY-Account avatar Feb 29 '24 21:02 PY-Account

Here's a sketch.

class PlutoColumnDynamic implements PlutoColumnType {
  @override
  int compare(a, b) => 0;

  @override
  bool isValid(value) => true;

  @override
  makeCompareValue(v) {}

  @override
  dynamic defaultValue;
}
  PlutoColumn test() => PlutoColumn(
        title: 'test',
        field: 'test',
        renderer: (rendererContext) => rendererContext.cell.value as Widget,
        type: PlutoColumnDynamic(),
      );
PlutoRow(
   cells: {
    'test': PlutoCell(value: Text('test2')),
   },
),

image

Unfortunately, there remains the problem of automatic height adjustment for PlutoRow, but I will try to solve this in another question (when it works, I will attach a link).

SnowyTusk avatar Mar 14 '24 13:03 SnowyTusk