How to remove or refresh table?
Hi, I want to replace all rows with new data. For the example, I create a table widget that will return PlutoGrid, and this widget required List<PlutoRow> rows like this.
Widget tableForm({
required List<PlutoRow> rows,
})
It's used on the main page like this below.
tableForm(rows: rowsInMainPage)
On the main page, I have a button to fetch new data and replace data in rowsInMainPage parm. This onTab function looks like this below.
void replaceRows() {
setState(() {
rowsInMainPage = [];
rowsInMainPage = newDataFromAnotherFunction;
});
}
But it does not work. The data are changed but the row does not change, How to make it work?
Now, I change the widget to class like this below.
Widget tableForm({
required List<PlutoRow> rows,
})
to
class TableForm {
PlutoGridStateManager? stateManager;
Wdiget showTable(){ ... }
void createColumn({ required List<TableColObj> columnTitle }){ ... }
void createRow({ required List<List<TableRowObject>> rowData }){ ... }
}
And I use the remove and append function in createRow() like this below.
try {
stateManager!.removeRows(stateManager!.rows);
rows = rowData
.where((e) => e.length >= columnTitleLength)
.map((e) => createPlutoRow(list: e))
.toList();
stateManager!.appendRows(rows);
} catch (e) {
rows = rowData
.where((e) => e.length >= columnTitleLength)
.map((e) => createPlutoRow(list: e))
.toList();
}
On the main page, I am using this class like this below.
TableForm tableForm = TableForm();
Future getDataFromApi() async {
rowData = fetchAndFormatData;
tableForm.createRow(rowData: rowData);
}
@override
void initState() {
tableForm.createColumn(columnTitle: columnTitle);
getDataFromApi();
super.initState();
}
This method can replace all rows(old data) with new rows(new data). If you added something that can fix this issue better than my method. Please share it. https://user-images.githubusercontent.com/59549741/162559604-47e4f9e9-517a-4306-896a-c1d6d7d27c3f.mp4
hi @SittiphanSittisak how you add below Footer since the default one looks different

This is custom with simple widget like Container, DropdownButton, Text, IconButon. :)
hi @SittiphanSittisak how you add below Footer since the default one looks different
This is custom with simple widget like Comtainer, DropdownButton, Text, IconButon. :)
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.