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
664 stars 305 forks source link

I added TextFormField in renderer , but not allow me to update its content[Bug] #904

Closed design2023 closed 1 year ago

design2023 commented 1 year ago

Steps to reproduce the bug

Renderer property.

Expected results

I want to update the cell by the content of TextFormField just.

Actual results

I make this to get the event onChange that exists in TextFormField to update the other cells during the writing.

Code sample

PlutoColumn(
        title: 'Weight',
        field: 'weight',
        type: PlutoColumnType.number(format: "###.###"),
        enableColumnDrag: false,
        enableAutoEditing: true,
        enableFilterMenuItem: true,
        enableContextMenu: false,
        suppressedAutoSize: true,
        enableEditingMode: false,
        textAlign: PlutoColumnTextAlign.center,
        renderer: (PlutoColumnRendererContext rendererParams) {
          return Container(
            child: TextFormField(
              controller: textEditWeight, 
              enabled: true,
              keyboardType: TextInputType.number,
              onChanged: (value) {
                print("On change ");

                double num = double.parse(value);
                String number = (num * 10).toInt().toString();
                textEditWeight.text = number;
                rendererParams.row.cells['count']!.value = number;
              },
            ),
          );
        },
      ),

Execution Environment

Flutter version

Flutter version is 3.0.6

PlutoGrid version PlutoGrid version is 7.0.2

OS Windows 11

design2023 commented 1 year ago

@bosskmk Can you help me, please?

miskerbirhanucse commented 1 year ago

do we have an update on this? I am facing the same issue.

design2023 commented 1 year ago

do we have an update on this? I am facing the same issue.

@miskerbirhanucse Yes, I used listener to add the content of the textField controller as :

import 'dart:html' as html;
  void initState() {
    super.initState();
  html.document.onKeyDown.listen((event) {
      setState(() {
        _lastKeyPressed = event.key!;

         // Check here and add the value to the controller of the TextField

      });
    });
}
miskerbirhanucse commented 1 year ago

@design2023 thanks for your reply. I have used multiple TextField, not one TextField. Do we have another solution?

design2023 commented 1 year ago

@miskerbirhanucse you are welcome. I have used multiple TextFiled also, just the difference is how to process it as a list of controllers linked with textFields.

github-actions[bot] commented 1 year ago

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

github-actions[bot] commented 1 year ago

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