Closed viniciushenr closed 4 years ago
I forget to say for everyone that could and want to help me with this issue, in the image all this values were inserted by the user. I started the table clean, the user insert the values and i don't know how to get all the values at once.
Hi @viniciushenr, upgrade to v1.1.3 of Editable and then do this:
/// Create a Key for EditableState
final _editableKey = GlobalKey<EditableState>();
/// Function to add a new row
/// Using the global key assigined to Editable widget
/// Access the current state of Editable
void _addNewRow() {
setState(() {
_editableKey.currentState.createRow();
});
}
///Print only edited rows.
void _printEditedRows() {
List editedRows = _editableKey.currentState.editedRows;
print(editedRows);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leadingWidth: 200,
leading: FlatButton.icon(
onPressed: () => _addNewRow(),
icon: Icon(Icons.add),
label: Text(
'Add',
style: TextStyle(fontWeight: FontWeight.bold),
)),
title: Text(widget.title),
actions: [
Padding(
padding: const EdgeInsets.all(8.0),
child: FlatButton(
onPressed: () => _printEditedRows(),
child: Text('Print Edited Rows',
style: TextStyle(fontWeight: FontWeight.bold))),
)
],
),
body: Editable(
key: _editableKey, //Assign Key to Widget
columns: cols,
rows: rows,
zebraStripe: true,
stripeColor2: Colors.grey[200],
borderColor: Colors.blueGrey,
),
);
}
Without any further response, I'm closing this issue
Yes, I'm sorry @godilite. I just saw your answer now, thank you very much, man. This package of yours is really amazing, and I'm very happy that you improved it so well. Thanks again, your answer that was exactly what I was looking for. ^^
Welcome @viniciushenr and thank you for using it. I'm also open for flutter/laravel gigs please.
You can also support this project by:
Thank you
I've tried using the onSubmitted and onRowSaved functions (but I'm not using SaveIcon).
I'm basically trying to figure out how to capture all the values entered in the cells, and print a List, for later use.
So, similar to how it is printed by onRowSaved (but I don't want to use this method because if the table has 100 rows, the user must press 100 SaveIcon).
I was thinking of putting the only button on the final screen, so when it was pressed, I could print this list with the values on my VSCode. But I don't know how to get these values, only having these two methods available (onSubmitted and onRowSaved).
My Screen:
My desired exit: List rows = [ {0: 100, 1: 200, 2: 300, 3: 400, 4: 500}, {0: 10, 1: 20, 2: 30, 3: 40, 4: 50}, ];