mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
fix search filter tabs and checkbox no data selection
This commit is contained in:
@ -22,7 +22,7 @@ class DynamicTable extends StatefulWidget {
|
||||
required this.headers,
|
||||
required this.data,
|
||||
required this.size,
|
||||
this.tableName,
|
||||
this.tableName,
|
||||
required this.isEmpty,
|
||||
required this.withCheckBox,
|
||||
required this.withSelectAll,
|
||||
@ -57,13 +57,19 @@ class _DynamicTableState extends State<DynamicTable> {
|
||||
}
|
||||
|
||||
void _initializeSelection() {
|
||||
_selected = List<bool>.generate(widget.data.length, (index) {
|
||||
// Check if the initialSelectedIds contains the deviceUuid
|
||||
// uuidIndex is the index of the column containing the deviceUuid
|
||||
final deviceUuid = widget.data[index][widget.uuidIndex];
|
||||
return widget.initialSelectedIds != null &&
|
||||
widget.initialSelectedIds!.contains(deviceUuid);
|
||||
});
|
||||
if (widget.data.isEmpty) {
|
||||
_selected = [];
|
||||
_selectAll = false;
|
||||
} else {
|
||||
_selected = List<bool>.generate(widget.data.length, (index) {
|
||||
// Check if the initialSelectedIds contains the deviceUuid
|
||||
// uuidIndex is the index of the column containing the deviceUuid
|
||||
final deviceUuid = widget.data[index][widget.uuidIndex];
|
||||
return widget.initialSelectedIds != null &&
|
||||
widget.initialSelectedIds!.contains(deviceUuid);
|
||||
});
|
||||
_selectAll = _selected.every((element) => element == true);
|
||||
}
|
||||
}
|
||||
|
||||
void _toggleRowSelection(int index) {
|
||||
@ -76,7 +82,6 @@ class _DynamicTableState extends State<DynamicTable> {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void _toggleSelectAll(bool? value) {
|
||||
setState(() {
|
||||
_selectAll = value ?? false;
|
||||
@ -125,7 +130,9 @@ class _DynamicTableState extends State<DynamicTable> {
|
||||
),
|
||||
Text(
|
||||
// no password
|
||||
widget.tableName=='AccessManagement'? 'No Password ' : 'No Devices',
|
||||
widget.tableName == 'AccessManagement'
|
||||
? 'No Password '
|
||||
: 'No Devices',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall!
|
||||
@ -178,8 +185,11 @@ class _DynamicTableState extends State<DynamicTable> {
|
||||
),
|
||||
),
|
||||
child: Checkbox(
|
||||
value: _selected.every((element) => element == true),
|
||||
onChanged:widget.withSelectAll?_toggleSelectAll:null,
|
||||
value: widget.data.isNotEmpty &&
|
||||
_selected.every((element) => element == true),
|
||||
onChanged: widget.withSelectAll && widget.data.isNotEmpty
|
||||
? _toggleSelectAll
|
||||
: null,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user