当前位置:网站首页>Problems encountered in using the Pluto table of the flutter plug-in
Problems encountered in using the Pluto table of the flutter plug-in
2022-06-13 12:00:00 【Sindyue】
- List data filtering and refresh Problem #438
https://github.com/bosskmk/pluto_grid/issues/438
After filtering the list data, refresh and load the data again. How to make the previous filtering conditions effective?
import 'package:flutter/material.dart';
import 'package:pluto_grid/pluto_grid.dart';
class EmptyScreen extends StatefulWidget {
static const routeName = 'empty';
const EmptyScreen({Key? key}) : super(key: key);
@override
_EmptyScreenState createState() => _EmptyScreenState();
}
class _EmptyScreenState extends State<EmptyScreen> {
late List<PlutoColumn> columns;
late List<PlutoRow> rows;
late PlutoGridStateManager stateManager;
final List<PlutoRow> filterRows = [];
@override
void initState() {
super.initState();
columns = [
PlutoColumn(
title: 'column1',
field: 'column1',
type: PlutoColumnType.text(),
),
PlutoColumn(
title: 'column2',
field: 'column2',
type: PlutoColumnType.text(),
),
PlutoColumn(
title: 'column3',
field: 'column3',
type: PlutoColumnType.text(),
),
];
_initData();
}
_initData() {
rows = [];
rows.addAll([
PlutoRow(
cells: {
'column1': PlutoCell(value: 'a1'),
'column2': PlutoCell(value: 'b1'),
'column3': PlutoCell(value: 'c1'),
},
),
PlutoRow(
cells: {
'column1': PlutoCell(value: 'a2'),
'column2': PlutoCell(value: 'b2'),
'column3': PlutoCell(value: 'c2'),
},
),
PlutoRow(
cells: {
'column1': PlutoCell(value: 'a3'),
'column2': PlutoCell(value: 'b3'),
'column3': PlutoCell(value: 'c3'),
},
),
]);
}
void handleSaveFilter() {
filterRows.clear();
final List<PlutoRow> filters = stateManager.filterRows
.map(
(e) => PlutoRow(cells: {
FilterHelper.filterFieldColumn: PlutoCell(
value: e.cells[FilterHelper.filterFieldColumn]!.value,
),
FilterHelper.filterFieldType: PlutoCell(
value: e.cells[FilterHelper.filterFieldType]!.value,
),
FilterHelper.filterFieldValue: PlutoCell(
value: e.cells[FilterHelper.filterFieldValue]!.value,
),
}),
)
.toList();
filterRows.addAll(filters);
}
void handleLoadFilter() {
stateManager.gridFocusNode?.unfocus();
WidgetsBinding.instance!.addPostFrameCallback((timeStamp) {
stateManager.setFilterWithFilterRows(filterRows);
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
padding: const EdgeInsets.all(15),
child: PlutoGrid(
columns: columns,
rows: rows,
onChanged: (PlutoGridOnChangedEvent event) {
print(event);
},
onLoaded: (PlutoGridOnLoadedEvent event) {
stateManager = event.stateManager;
stateManager.setShowColumnFilter(true);
},
configuration: const PlutoGridConfiguration(),
createHeader: (_) {
return Row(
children: [
TextButton(
onPressed: handleSaveFilter,
child: const Text('save filter'),
),
TextButton(
onPressed: handleLoadFilter,
child: const Text('load filter'),
),
],
);
},
),
),
);
}
}
The core is the above method of saving and loading filter conditions . Function can be realized , All data will be loaded first in the middle , Then display the filtered data list .
2. update the single rowData #439
solution:
Would you like to use the below method of stateManager ?
void insertRows(int rowIdx, List<PlutoRow> rows);
void removeRows(List<PlutoRow> rows);
another solution:
PlutoRow newRow = PlutoRow(
cells: {
'column_1': PlutoCell(value: value.toString()),
'column_2': PlutoCell(value: value.toString()),
'column_3': PlutoCell(value: value.toString()),
'column_4': PlutoCell(value: value.toString()),
'column_5': PlutoCell(value: value.toString()),
},
);
stateManager.prependRows([newRow]);
stateManager.moveScrollByRow(PlutoMoveDirection.up, 1);
stateManager.setCurrentCell(newRow.cells.entries.first.value, 0);
stateManager.changeCellValue(
stateManager.currentRow!.cells['column_1']!,
value,
force: true,
);
var newValue = {
};
newValue['tag'] = cell.value['tag'];
newValue['ctime'] = cell.value['ctime'];
newValue['confirmstate'] = cell.value['confirmstate'];
List<String> list = [];
list.add(_inputDispose);
newValue['dispose'] = list;
stateManager!.changeCellValue(cell, newValue, force: true);
https://weblaze.dev/pluto_grid/build/web/#feature/listing-mode – For this example, please refer to
边栏推荐
- Product story | YuQue drawing board you don't know
- 基于三维GIS技术的行业发展及研究现状
- web開發項目,web單頁開發
- 7.5.4:Spire Office for .NET New Version
- 2022.2:EyeshotPro EyeshotUltimate EyeshotFem
- Wallys/Network_ Card/DR-NAS26/AR9223/2x2 MIMO
- 基于STM32F103——DS1302日期时间+串口打印
- [tcapulusdb knowledge base] tcapulusdb doc acceptance - table creation approval introduction
- 我是如何解决码云图床失效问题?
- Seccloud and trend technology jointly release the overall solution of container cloud platform and GPU resource pooling
猜你喜欢

SMS sending + serial port printing based on stm32f103-sim900a

面试突击56:聚簇索引和非聚簇索引有什么区别?

塔米狗股权项目分享:北京化大化新科技股份有限公司163.79万股股份转让

Web development video tutorial, web development teaching
![[tcapulusdb knowledge base] tcapulusdb doc acceptance - Introduction to creating game area](/img/b7/2358e8cf1cdaeaba77e52d04cc74d4.png)
[tcapulusdb knowledge base] tcapulusdb doc acceptance - Introduction to creating game area
![[tcapulusdb knowledge base] Introduction to tcapulusdb analytical text export](/img/ab/e6241f635c6736a0d6877ae4cf10df.png)
[tcapulusdb knowledge base] Introduction to tcapulusdb analytical text export

What is the appropriate setting for the number of database connections?

14、wpf之Border装饰器使用小记

【TcaplusDB知识库】TcaplusDB-tcapsvrmgr工具介绍(一)

The most complete network, including interview questions + Answers
随机推荐
Auto. JS floating window centered
智能客服系统框架rasa
break algorithm---dynamic planning(dp-arr)
Text error correction -- crisp model
Socket programming (medium)
全网最全,含面试题+答案
复习指南,学生党必看
[tcaplusdb knowledge base] Introduction to tcaplusdb tcaplusadmin tool
Audio and video technology development weekly 𞓜 249
Books + videos + learning notes + skill improvement resource library, interview must ask
docker Dockerfile安装mysql5.7
2022年二建《市政》科目答案已出,请收好
基于STM32F103——矩阵按键+串口打印
LVGL库入门教程01-移植到STM32(触摸屏)
2022.2:EyeshotPro EyeshotUltimate EyeshotFem
1051. 高度检查器
[tcapulusdb knowledge base] Introduction to tcapulusdb table data caching
以梦为马之89c51单片机驱动lcd
燃油方案和产品业务建模
查询当前电脑cpu核心数