Adding Icon into DataGridCell

Hi there, hope you are all fine.

May you help me on how to add an Icon to a dataGridCell?

I had no problem adding Icon to a column header, but I couldn't find a way to do the same to a dataGridCell.

dataGridCell_1.PNG

Adding Icon to column header:

dataGridCell_2.PNG


5 Replies

RS Renugadevi Sadagoban Syncfusion Team July 1, 2021 01:25 PM UTC

Hi Xavier,  
  
Greetings from syncfusion.  
  
You can achieve your requirement by loading the Icon widget to the corresponding cell of DataGridRowAdaptor in DataGridSource.buildRow method .  
 
Here we have added the location icon along with the location name to the location column. Please check the following code snippet. 
 
 
  @override 
  DataGridRowAdapter buildRow(DataGridRow row) { 
    return DataGridRowAdapter(cells: [ 
      Container( 
        alignment: Alignment.center, 
        padding: EdgeInsets.symmetric(horizontal: 16), 
        child: Text(row.getCells()[0].value.toString()), 
      ), 
      Container( 
        alignment: Alignment.center, 
        padding: EdgeInsets.symmetric(horizontal: 16), 
        child: Text(row.getCells()[1].value), 
      ), 
      Container( 
        alignment: Alignment.center, 
        padding: EdgeInsets.symmetric(horizontal: 16), 
        child: Text(row.getCells()[2].value.toString()), 
      ), 
      Container( 
          alignment: Alignment.center, 
          padding: EdgeInsets.symmetric(horizontal: 16), 
          child:  Row(children: [Icon(Icons.location_on),Text(row.getCells()[3].value)],)) 
    ]); 
  } 
 
 
 
We have prepared following sample for your reference, 
 
Please let us know if you require any further assistance. 
  
Regards, 
Renuga devi S 



XL Xavier Langa July 1, 2021 02:53 PM UTC

Hi there,

I can't access sample in that link. Here is the message I get:





RS Renugadevi Sadagoban Syncfusion Team July 1, 2021 03:56 PM UTC

Hi Xavier, 
 
Sorry for the inconvenience, 
 
Please refer the following sample, 
 
 
 
Please let us know if you require any further assistance. 
  
Regards, 
Renuga devi S 



XL Xavier Langa replied to Xavier Langa July 1, 2021 05:01 PM UTC

Many thanks, very helpful..



RS Renugadevi Sadagoban Syncfusion Team July 2, 2021 05:42 AM UTC

Hi Xavier, 
Thanks for your update. 
Please get back to us if you require any further assistance. We will be happy to assist you. 
Regards, 
Renuga devi S 


Loader.
Up arrow icon