How to custom SfDataGrid when editting

Hi Syncfusion support,

  1. How to change the border color like Red color in cell when I focus to edit. How to do that?
  2. How to remove padding content of the cell when I edit where inside orange color in my photo?
  3. How to type which format of column?
  4. On IOS, how to remove border of TextField when edit?

Thanks you



3 Replies

KK Karthikraja Kalaimani Syncfusion Team August 3, 2021 10:46 AM UTC

Hi Nguyen, 

Thank you for contacting Syncfusion support. 

Query 1 : How to change the border color like Red color in cell when I focus to edit. How to do that?  

Please refer to the below code snippets to achieve your requirement.  

Code snippets : 
<sfgrid:SfDataGrid x:Name="dataGrid"
                               ItemsSource="{Binding OrdersInfo}"

                              CurrentCellBeginEdit="dataGrid_CurrentCellBeginEdit"
                               CurrentCellEndEdit="dataGrid_CurrentCellEndEdit"
                               AutoGenerateColumns="False"
                               ColumnSizer="Star"
                               AllowEditing="True"
                               SelectionMode="Single"
                               NavigationMode="Cell">

                <sfgrid:SfDataGrid.Columns >
                    <sfgrid:GridTextColumn MappingName="OrderID"/>
                    <sfgrid:GridTextColumn MappingName="CustomerID"></sfgrid:GridTextColumn>
                    <sfgrid:GridTextColumn MappingName="FirstName"></sfgrid:GridTextColumn>
                </sfgrid:SfDataGrid.Columns>
            </sfgrid:SfDataGrid>   

private async void dataGrid_CurrentCellEndEdit(object sender, GridCurrentCellEndEditEventArgs e)
        {
            await Task.Delay(30);
            this.dataGrid.GridStyle.CurrentCellBorderColor = Color.Blue;
        }

        private async void dataGrid_CurrentCellBeginEdit(object sender, GridCurrentCellBeginEditEventArgs e)
        {
            this.dataGrid.GridStyle.CurrentCellBorderColor = Color.Red;
        }

Query 2 : How to remove padding content of the cell when I edit where inside orange color in my photo?

We are unable to change that padding size only for that cell in edit mode. Since we have provided padding support for GridColumns. So, if we applied padding to GridColumns it will apply to the edit and non edit mode cells. We suggest you to use TemplateColumns because the template column will layout the template views to whole cell. For more details please refer to the below UG link. 

UG link :https://help.syncfusion.com/xamarin/datagrid/column-types#edit-template


Query 3 : How to type which format of column?

By default, the numeric keyboard will show while typing on Numeric Column and qwerty keyboard will show while typing on Text Column.

Query 4 : On IOS, how to remove border of TextField when edit?

We can set the border color to transparent on BeginEdit event of the SfDataGrid. Please refer to the below code snippets. 

Code snippets : 
  private async void dataGrid_CurrentCellBeginEdit(object sender, GridCurrentCellBeginEditEventArgs e)
        {
            this.dataGrid.GridStyle.CurrentCellBorderColor = Color.Transparent;
        }

Regards,
Karthik Raja





NK Nguyen Khoa Lu August 4, 2021 03:58 AM UTC

Thanks for your solutions, it works for me.



KK Karthikraja Kalaimani Syncfusion Team August 4, 2021 04:30 AM UTC

Hi Nguyen,

Thanks for the update.

We glad to know that the previously provided solution has meets your requirement. Please let us know if you need further assistance from us.

Regards,
Karthik Raja5


Loader.
Up arrow icon