Closed MukeshWrms closed 1 month ago
Hi @MukeshWrms ,
You can build DataGrid rows in the DataSource by concatenating two or more values into a single row. In our example, the SfDataGrid widget defines a column named name_designation, where the concatenated values of the name and designation fields are displayed. In the DataSource class, the DataGridCell
We have included a sample for your reference. Please review it for more details and adapt it to suit your specific requirements.
Regards, Abinesh P
this is working but, i have used user image url and name how can do this.
DataGridCell( columnName: 'asset', value: '${e.assetIconUrl} - ${e.assetName}'),
// Avatar cell if (dataGridCell.columnName == 'asset') { if (dataGridCell.value == null) return Container(); return Row( children: [ Padding( padding: const EdgeInsets.only(left: 4.0, right: 4), child: Container( alignment: Alignment.centerLeft, width: 35, height: 35, child: CustomImageWithType( url: dataGridCell.value.toString(), fit: BoxFit.cover, height: 35, width: 35, ), ), ), Text('Income'), ], ); }
with image execution given the error only image value is working but with concatenates other is not working.
Hi @MukeshWrms ,
Based on your requirements, we have prepared a sample to concatenate the image and name values. In our example, we use a Map<String, dynamic> in the DataGridCell to hold both the image and the name. This allows us to store and access these two different types of data together. The column named image_name will hold both the image and the name, with the value being a map that contains the image (e.image) and the name (e.name).
We have included a sample for your reference. Please review it for more details and adapt it to suit your specific requirements.
Regards, Abinesh P
Thanks its working .
Use case
i have need the one column under two or more value show
country and department
how can do this
DataSourceDepartment({required List employeeData}) {
_employeeData = employeeData
.map((e) => DataGridRow(cells: [
DataGridCell(
columnName: 'id',
value: getReturnSr(employeeData.indexOf(e))),
DataGridCell(columnName: 'project', value: e.projectName),
DataGridCell(columnName: 'country', value: e.level1Name),
DataGridCell(
columnName: 'department', value: e.level2Name.toString()),
}
Proposal
i have need the one column under two or more value show
country and department
how can do this
DataSourceDepartment({required List employeeData}) {
_employeeData = employeeData
.map((e) => DataGridRow(cells: [
DataGridCell(
columnName: 'id',
value: getReturnSr(employeeData.indexOf(e))),
DataGridCell(columnName: 'project', value: e.projectName),
DataGridCell(columnName: 'country', value: e.level1Name),
DataGridCell(
columnName: 'department', value: e.level2Name.toString()),
}