setColumnLayoutFromJson method
dynamic
setColumnLayoutFromJson(
{ - required String jsonStr,
})
Implementation
setColumnLayoutFromJson({required String jsonStr}) {
if (_controller.state == null) {
return;
}
var map = json.decode(jsonStr);
// Reorder and set column widths
var colDefs = _controller.state!.columnDefs.toList(growable: true);
_controller.state!.columnDefs.clear();
for (Map colLayout in map) {
var id = colLayout['id'];
var width = colLayout['columnWidth'];
var colDef = colDefs.firstWhereOrNull((i) => i.id == id);
if (colDef != null) {
colDef.columnWidth = width;
_controller.state!.columnDefs.add(colDef);
colDefs.remove(colDef);
}
}
//Add Columns missing in the Layout
for (var colDef in colDefs) {
_controller.state!.columnDefs.add(colDef);
//TODO hide the column
}
_controller.state!.colLeftCache.clear();
_controller.widgetState!.refresh();
}