Add DropdownButton as GridWidgetColumn in DataGrid

Hi, I would like to add a DropdownButton inside DataGrid using GridWidgetColumn but it does not show up anything but only a blank space. Is there any example for me to refer to?

Thank you so much.

5 Replies

BS Balasubramani Sundaram Syncfusion Team December 10, 2020 09:56 AM UTC

Hi Allen,  
 
Thank you for contacting Syncfusion support. 
 
We have prepared a simple sample of DataGrid with GridWidgetColumn and the widget column is loaded with DropDownButton. 
 
Please refer the sample and UG for your reference. 
 
 
 
 
 
Regards,
Balasubramani Sundaram. 
 
 



AL allen lim December 11, 2020 08:42 AM UTC

Thank you for the sample, I am able to get the expected result. May I ask if I can get the current cell details in onChange method when selecting one of the drop-down field value?

Thank you.


BS Balasubramani Sundaram Syncfusion Team December 14, 2020 03:03 PM UTC

Hi Allen,  
 
Thanks for your update,  
 
We suspect that your requirement to get the current cell row-column index on onChange event in DropDownWidget. You can get the current cell details from the DataGridController.currentCell for that you must set the navigationMode to GridNavigationMode.cell and if you didn’t want the current cell border, please set the current cell border color to transparent.   
 
Please refer the below UG for more details, 
 
 
CurrentCell Border Customization UG link : https://help.syncfusion.com/flutter/datagrid/selection#current-cell 
 
Regards,  
Balasubramani Sundaram.   



AL allen lim December 15, 2020 12:06 AM UTC

Hi,

I am actually trying to get one GridTextColumn value of my selected row, eg: I want to get GridTextColumn value of selected row which is storing my item Id to be passed when I click on the dropdown button.

Thank you.


BS Balasubramani Sundaram Syncfusion Team December 15, 2020 03:32 PM UTC

Hi Allen,  
Thanks for your update,  
You can achieve your requirement of get the selected row rowData from the ‘DataGridController.selectedRow’ API. From the selected rowData you can retrieve the required data. Please refer the below code snippet and UG for more reference. 
Code Snippet: 
 
final DataGridController _dataGridController = DataGridController(); 
 
@override 
Widget build(BuildContext context){ 
  return Scaffold( 
      body: Column( 
          children:[ 
            FlatButton( 
                child: Text('Get Selection Information'), 
                onPressed: () {                 
                  //SelectedRow     
                  var _selectedRow = this._dataGridController.selectedRow; 
                  print(_selectedRow); 
                }), 
            Expanded( 
                child: SfDataGrid( 
                    source: _employeeDataSource, 
                    columns: [ 
                      GridNumericColumn(mappingName: 'id', headerText: 'ID'), 
                      GridTextColumn(mappingName: 'name', headerText: 'Name'), 
                      GridTextColumn(mappingName: 'designation', headerText: 'Designation'), 
                      GridNumericColumn(mappingName: 'salary', headerText: 'Salary') 
                    ], 
                    controller: _dataGridController, 
                    selectionMode: SelectionMode.single 
                )) 
          ] 
      ) 
  ); 
} 
 
 
 
 
Regards,  
Balasubramani Sundaram. 
 
 
 


Loader.
Up arrow icon