New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pagination not working ? #30
Comments
I updated the example for you, but in short it is a stateless data table so you need to handle that: class JsonExample extends StatefulWidget {
@override
_JsonExampleState createState() => _JsonExampleState();
}
class _JsonExampleState extends State<JsonExample> {
int _rowsPerPage = 100;
int _sortColumnIndex;
bool _sortAscending = true;
List<Map<String, dynamic>> _items = [];
int _rowsOffset = 0;
@override
void initState() {
_items = List.from(jsonDecode(JSON_DATA));
super.initState();
}
int index = 0;
@override
Widget build(BuildContext context) {
final _rows = min(40, _items.length);
return Scaffold(
appBar: AppBar(
title: const Text('Data Table Example'),
),
// body: buildDataTable(),
body: _items == null || _items.isEmpty
? const Center(child: CircularProgressIndicator())
: NativeDataTable.fromJson(
showSelect: false,
showSort: false,
items: _items,
firstRowIndex: index,
rowsPerPage: _rows,
handleNext: () {
if (mounted) {
setState(() {
if (index == _items.length - 1) {
index = _items.length - 1;
} else {
index += _rows;
}
});
}
},
handlePrevious: () {
if (mounted) {
setState(() {
if (index == 0) {
index = 0;
} else {
index -= _rows;
}
});
}
},
),
);
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
thanks for this package.
I'm trying to use the pagination but I can't find out how it works.
In the demo version https://rodydavis.github.io/data_tables/#/
at the bottom it shows 1-40 of 200 but the next button is disabled. I have the same "issue"
Should I manage pagination by myself with handleNext callback?
Thanks
The text was updated successfully, but these errors were encountered: