xBuilder_XCell_InEdit method

Widget? xBuilder_XCell_InEdit(
  1. DataGridCell gridCell,
  2. RowColumnIndex rowColumnIndex,
  3. GridColumn column,
  4. CellSubmit submitCell,
)
inherited

settare il value in cellInEdit_Value e chiamare submitCell()

Implementation

Widget? xBuilder_XCell_InEdit(DataGridCell gridCell, RowColumnIndex rowColumnIndex, GridColumn column, CellSubmit submitCell) {
  if (gridCell.value!.runtimeType == String) {
    return XTextFormField(
        autoFocus: true,
        height: null,
        initialValue: gridCell.value,
        borderVisible: false,
        onChanged: (value) {
          cellInEdit_Value = value;
        },
        labelStyle: XStyles.xStyTextForLabel(textColor: enterpriseMode ? XColors.enterpriseMode_Foreground : XColors.foregroundLight),
        textColor: enterpriseMode ? XColors.enterpriseMode_Foreground : XColors.foregroundLight,
        onFieldSubmitted: (value) {
          var oldVal = get_ItemPropValue(rowColumnIndex, column);
          print("value:" + value!);
          print("oldVal:" + oldVal);
          if (oldVal != cellInEdit_Value) {
            submitCell();
          }
        });
  } else if (gridCell.value!.runtimeType == DateTime) {
    return DateTimeFormField(
      decoration: InputDecoration(
        labelStyle: XStyles.xStyTextForSubLabel(textColor: enterpriseMode ? XColors.enterpriseMode_Foreground : XColors.foregroundLight),
        hintStyle: enterpriseMode ? XStyles.xStyTextForSubDescr(textColor: XColors.enterpriseMode_Foreground) : textStyleDescr,
        errorStyle: TextStyle(color: Colors.redAccent),
      ),
      onSaved: (date) {
        submitCell();
      },
      onChanged: (value) => cellInEdit_Value = value,
      initialValue: gridCell.value,
      materialDatePickerOptions: MaterialDatePickerOptions(
        initialEntryMode: DatePickerEntryMode.input,
        initialDatePickerMode: DatePickerMode.year,
      ),
      style: enterpriseMode ? XStyles.xStyTextForSubDescr(textColor: XColors.enterpriseMode_Foreground) : textStyleDescr,
      dateFormat: DateFormat("dd MMMM yyyy"),
      mode: DateTimeFieldPickerMode.date,
      autovalidateMode: AutovalidateMode.onUserInteraction,
    );
  } else if (gridCell.value!.runtimeType == double || gridCell.value!.runtimeType == int) {
    return XTextFormField(
        autoFocus: true,
        height: null,
        initialValue: gridCell.value != null && gridCell.value != 0 ? gridCell.value.toString() : "",
        borderVisible: false,
        onChanged: (value) {
          if (value.isNotEmpty) {
            cellInEdit_Value = gridCell.value!.runtimeType == int ? int.parse(value) : double.parse(value);
          } else {
            cellInEdit_Value = 0;
          }
        },
        labelStyle: XStyles.xStyTextForLabel(textColor: enterpriseMode ? XColors.enterpriseMode_Foreground : XColors.foregroundLight),
        textColor: enterpriseMode ? XColors.enterpriseMode_Foreground : XColors.foregroundLight,
        onFieldSubmitted: (value) {
          var oldVal = get_ItemPropValue(rowColumnIndex, column);
          if (oldVal != cellInEdit_Value) {
            submitCell();
          }
        });
  } else {
    return Container();
  }
}