how to combine static column with dynamic?
example
The first 3 columns are static and the next column the column data fetch from json
|
factory _ProductFromJson.fromJson(Map<String, dynamic> json, int index) {
return _ProductFromJson(
id: productCollection[index].id,
contactName: productCollection[index].contactName,
companyName: productCollection[index].companyName,
city: json['city'],
country: json['country'],
designation: json['designation']);
} |
can you share the product_data json file?
sorry, what I mean is that the dynamized column is the column header,
column headers can be incremented according to json data
|
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Flutter DataGrid Demo'),
),
body: FutureBuilder
future: generateProductList(),
builder: (context, snapShot) {
if (snapShot.hasData) {
var jsonColumns = snapShot.data![0];
_employeeDataGridSource.columns = jsonColumns.keys.toList();
// create static columns
_employeeDataGridSource.columns.insert(0, 'id');
_employeeDataGridSource.columns.insert(1, 'designation');
_employeeDataGridSource.columns.insert(2, 'salary');
return SfDataGrid(
source: _employeeDataGridSource,
columns: _employeeDataGridSource.columns
.map
columnName: columnName,
label: Container(
padding: EdgeInsets.all(3),
alignment: Alignment.center,
child: Text(
columnName.toUpperCase(),
overflow: TextOverflow.ellipsis,
),
)))
.toList());
}
return Center(
child: CircularProgressIndicator(),
);
},
));
} |
Renugadevi
thank you very much, i will try