diff --git a/win_text_editor/lib/modules/code_creater/widgets/node_table.dart b/win_text_editor/lib/modules/code_creater/widgets/node_table.dart index fc52c73..cf3df02 100644 --- a/win_text_editor/lib/modules/code_creater/widgets/node_table.dart +++ b/win_text_editor/lib/modules/code_creater/widgets/node_table.dart @@ -81,6 +81,12 @@ class _NodeTableState extends State { onRowDoubleTap: (event) { _selectedRowIndex = event.rowIdx; }, + rowColorCallback: (rowContext) { + // 当行被选中时设置背景色 + return rowContext.stateManager.currentRow?.key == rowContext.row.key + ? Colors.blue[200]! // 选中行颜色 + : Colors.white; // 默认行颜色(不能返回 null) + }, ), ), ), @@ -163,12 +169,23 @@ class _NodeTableState extends State { List _buildColumns() { return [ - MyPlutoColumn(title: '#', field: 'rowNum', width: 40), - MyPlutoColumn(title: '成员', field: 'content', width: 300), + MyPlutoColumn( + title: '#', + field: 'rowNum', + width: 40, + enableRowChecked: false, // 允许整行选中 + ), + MyPlutoColumn( + title: '成员', + field: 'content', + width: 300, + enableRowChecked: false, // 允许整行选中 + ), MyPlutoDropdownColumn( title: '操作类型', field: 'type', width: 120, + enableRowChecked: false, // 允许整行选中 optionsBuilder: (rowKey) { final data = _nodeTypeData[rowKey as ValueKey]; return _getOptions(data?.originalType ?? ''); diff --git a/win_text_editor/lib/modules/xml_search/widgets/results_view.dart b/win_text_editor/lib/modules/xml_search/widgets/results_view.dart index c89c06d..fc7ae22 100644 --- a/win_text_editor/lib/modules/xml_search/widgets/results_view.dart +++ b/win_text_editor/lib/modules/xml_search/widgets/results_view.dart @@ -139,7 +139,7 @@ class _ResultsViewState extends State { List _buildColumns() { return [ - MyPlutoColumn(title: '#', field: 'rowNum', width: 60, checkable: true), + MyPlutoColumn(title: '#', field: 'rowNum', width: 60, enableRowChecked: true), MyPlutoColumn( title: '搜索内容', field: 'content', diff --git a/win_text_editor/lib/shared/components/my_pluto_column.dart b/win_text_editor/lib/shared/components/my_pluto_column.dart index c0058ca..852063d 100644 --- a/win_text_editor/lib/shared/components/my_pluto_column.dart +++ b/win_text_editor/lib/shared/components/my_pluto_column.dart @@ -8,7 +8,7 @@ class MyPlutoColumn extends PlutoColumn { dynamic type, double width = 80, bool editable = false, - bool checkable = false, + bool enableRowChecked = false, bool enableSorting = false, bool autoSize = false, Widget Function(PlutoColumnRendererContext)? renderer, @@ -18,7 +18,7 @@ class MyPlutoColumn extends PlutoColumn { field: field, type: type ?? PlutoColumnType.text(defaultValue: ''), width: width, - enableRowChecked: checkable, + enableRowChecked: enableRowChecked, enableContextMenu: false, enableEditingMode: editable, enableSorting: enableSorting, diff --git a/win_text_editor/lib/shared/components/my_pluto_configuration.dart b/win_text_editor/lib/shared/components/my_pluto_configuration.dart index 1de717b..cd0e071 100644 --- a/win_text_editor/lib/shared/components/my_pluto_configuration.dart +++ b/win_text_editor/lib/shared/components/my_pluto_configuration.dart @@ -6,12 +6,21 @@ import 'package:pluto_grid/pluto_grid.dart'; class MyPlutoGridConfiguration extends PlutoGridConfiguration { MyPlutoGridConfiguration() : super( - style: const PlutoGridStyleConfig( + style: PlutoGridStyleConfig( rowHeight: 32, columnHeight: 32, iconColor: Colors.transparent, gridBorderRadius: BorderRadius.zero, - columnTextStyle: TextStyle( + enableGridBorderShadow: true, + gridBorderColor: Colors.grey, + activatedColor: Colors.blue[200]!, + activatedBorderColor: Colors.grey!, + inactivatedBorderColor: Colors.grey, + gridBackgroundColor: Colors.white, + cellColorInEditState: Colors.white, + defaultCellPadding: const EdgeInsets.all(8), + cellTextStyle: const TextStyle(color: Colors.black), + columnTextStyle: const TextStyle( color: Colors.black, fontSize: 14, fontWeight: FontWeight.normal, diff --git a/win_text_editor/lib/shared/components/my_pluto_dropdown_column.dart b/win_text_editor/lib/shared/components/my_pluto_dropdown_column.dart index 72535a6..33fa387 100644 --- a/win_text_editor/lib/shared/components/my_pluto_dropdown_column.dart +++ b/win_text_editor/lib/shared/components/my_pluto_dropdown_column.dart @@ -9,7 +9,7 @@ class MyPlutoDropdownColumn extends PlutoColumn { required String field, this.optionsBuilder, double width = 200, - bool checkable = false, + bool enableRowChecked = false, bool enableSorting = false, bool autoSize = false, PlutoColumnTextAlign textAlign = PlutoColumnTextAlign.start, @@ -18,7 +18,7 @@ class MyPlutoDropdownColumn extends PlutoColumn { field: field, type: PlutoColumnType.text(defaultValue: ''), width: width, - enableRowChecked: checkable, + enableRowChecked: enableRowChecked, enableContextMenu: false, enableEditingMode: true, enableSorting: enableSorting, @@ -33,14 +33,13 @@ class MyPlutoDropdownColumn extends PlutoColumn { final currentValue = rendererContext.row.cells[field]!.value.toString(); return DropdownButton( - value: options.contains(currentValue) + value: + options.contains(currentValue) ? currentValue : (options.isNotEmpty ? options.first : ''), - items: options - .map((value) => DropdownMenuItem( - value: value, - child: Text(value), - )) + items: + options + .map((value) => DropdownMenuItem(value: value, child: Text(value))) .toList(), onChanged: (newValue) { if (newValue != null) { @@ -58,10 +57,7 @@ class MyPlutoDropdownColumn extends PlutoColumn { iconSize: 24, isExpanded: true, underline: Container(), // 移除下划线 - style: TextStyle( - fontSize: 14, - color: Colors.black87, - ), + style: const TextStyle(fontSize: 14, color: Colors.black87), dropdownColor: Colors.white, elevation: 2, borderRadius: BorderRadius.circular(4),