How to call BeginEdit and EndEdit Method on Xamarin.Android ?

I have created a template column cell.And my output comes as i expected. but when i give value on custom maskedit control the CurrentCellEndedit not triggered.
Even i tried with CurrentCellBeginEdit.

Please help me on the above query ASAP.

Code: 
DataGrid.cs

var Column = new GridTextColumn();
Column.MappingName = element.ElementName;
Column.HeaderText = element.Caption;
Column.UserCellType = typeof(CustomMaskEdit);
Column.TextMargin = 2;
Column.LoadUIView = true;

datagrid.CurrentCellEndEdit+=(s,e)
{
     //Not Triggered.
};

 


6 Replies 1 reply marked as answer

CS Chandrasekar Sampathkumar Syncfusion Team April 1, 2021 02:46 PM UTC

Hi Bharath, 
Thank you for using Syncfusion products. 
We have checked the reported query from our end. We have prepared simple sample based on your requirement and we regret to let you know that we are not able to replicate the reported issue. We have attached the tested sample for your reference and you can download the same using the following link, 
Could you please replicate the issue for us in the provided sample or share the code snippets for CustomMaskEdit which would be helpful for us to check on it and provide you solution at the earliest. 
Regards, 
Chandrasekar Sampathkumar 



BH Bharath April 2, 2021 07:11 AM UTC

Can you please share me the example for MaskEdit Column Cell on Xamarin Android ?


KK Karthikraja Kalaimani Syncfusion Team April 5, 2021 07:29 AM UTC

Hi Bharath,

We have checked with SfMaskedEdit control and we saw that when tap on gridcell the focus goes to SfMaskedEdit control because SfMaskedEdit is an editable control. So, only the begin edit and end edit event’s are not triggered. However, you can write your begin edit operation and end edit operation on FocusChange event of the SfMaskedEdit control. Please refer to the below code snippet and attached sample.

Code snippet :

 
public class CustomCell : GridCell 
    { 
 
        SfMaskedEdit maskedEdit; 
 
        public CustomCell(Context context) : base(context) 
        { 
           maskedEdit = new SfMaskedEdit(context); 
            maskedEdit.Mask = "00/00/0000"; 
            maskedEdit.Value = @"14/11/2014"; 
            maskedEdit.Focusable = true; 
            this.maskedEdit.FocusChange += MaskedEdit_FocusChange1; 
            this.AddView(maskedEdit); 
        } 
 
        private void MaskedEdit_FocusChange1(object sender, FocusChangeEventArgs e) 
        { 
            if (e.HasFocus) 
            { 
                //BeginEdit operation 
            } 
            else 
            {  
               //EndEdit opertation 
            } 
        } 
 
        protected override void OnDraw(Canvas canvas) 
        { 
            base.OnDraw(canvas); 
        } 
    } 



BH Bharath replied to Karthikraja Kalaimani April 7, 2021 04:50 AM UTC

Hi Bharath,

We have checked with SfMaskedEdit control and we saw that when tap on gridcell the focus goes to SfMaskedEdit control because SfMaskedEdit is an editable control. So, only the begin edit and end edit event’s are not triggered. However, you can write your begin edit operation and end edit operation on FocusChange event of the SfMaskedEdit control. Please refer to the below code snippet and attached sample.

Code snippet :

 
public class CustomCell : GridCell 
    { 
 
        SfMaskedEdit maskedEdit; 
 
        public CustomCell(Context context) : base(context) 
        { 
           maskedEdit = new SfMaskedEdit(context); 
            maskedEdit.Mask = "00/00/0000"; 
            maskedEdit.Value = @"14/11/2014"; 
            maskedEdit.Focusable = true; 
            this.maskedEdit.FocusChange += MaskedEdit_FocusChange1; 
            this.AddView(maskedEdit); 
        } 
 
        private void MaskedEdit_FocusChange1(object sender, FocusChangeEventArgs e) 
        { 
            if (e.HasFocus) 
            { 
                //BeginEdit operation 
            } 
            else 
            {  
               //EndEdit opertation 
            } 
        } 
 
        protected override void OnDraw(Canvas canvas) 
        { 
            base.OnDraw(canvas); 
        } 
    } 


Thanks, One more thing how to update column cell value on runtime.Currently,  i am  binding datatable on itemsource and i have used INotifypropertyChanged, but its not working.



CS Chandrasekar Sampathkumar Syncfusion Team April 7, 2021 10:24 PM UTC

Hi Bharath, 
Thank you for the update. 
We are currently validating the reported scenario and update your further details by two business days (April 9th, 2021). We appreciate your patience until then. 
Regards, 
Chandrasekar Sampathkumar 



CS Chandrasekar Sampathkumar Syncfusion Team April 9, 2021 09:07 PM UTC

Hi Bharath, 
Thank you for your patience. 
Please refer the following code snippets to achieve your requirement, 
Step 1: Using INotifyPropertyChanged 
public class ViewModel : INotifyPropertyChanged 
{ 
    public ViewModel() 
    { 
        SetRowsToGenerate(6); 
    } 
 
    private DataTable dataTable; 
 
    public DataTable DataTable 
    { 
        get { return dataTable; } 
        set  
        { 
            this.dataTable = value; 
            RaisePropertyChanged("DataTable"); 
        } 
    } 
 
    public event PropertyChangedEventHandler PropertyChanged; 
    private void RaisePropertyChanged(String Name) 
    { 
        if (PropertyChanged != null) 
            this.PropertyChanged(this, new PropertyChangedEventArgs(Name)); 
    } 
} 
Step 2: In OnDraw method, set the MaskedEdit value from DataColumn.CellValue 
public class CustomCell : GridCell 
{ 
    SfMaskedEdit maskedEdit; 
 
    public CustomCell(Context context) : base(context) 
    { 
        maskedEdit = new SfMaskedEdit(context); 
        maskedEdit.Mask = @"00/00/0000"; 
        maskedEdit.Focusable = true; 
        this.maskedEdit.FocusChange += MaskedEdit_FocusChange1; 
        this.AddView(maskedEdit); 
    } 
 
    protected override void OnDraw(Canvas canvas) 
    { 
        base.OnDraw(canvas); 
 
        if (maskedEdit.Value.ToString() == "") 
        { 
            //During initialization, Update the MaskedEdit value with the DataTable value 
            maskedEdit.Value = (DataColumn.CellValue.ToString()); 
        } 
        else if (maskedEdit.Value.ToString() != "" && DataColumn.CellValue.ToString() != maskedEdit.Value.ToString()) 
        { 
            //On Editing, Update the DataTable value with the MaskedEdit value 
            DataColumn.Renderer.DataGrid.View.GetItemProperties(). 
            SetValue(DataColumn.RowData, maskedEdit.Value.ToString(), DataColumn.GridColumn.MappingName); 
        }             
    } 
} 
Step 3: Set the DataTable as DataGrid ItemsSource 
protected override void OnCreate(Bundle savedInstanceState) 
{ 
    base.OnCreate(savedInstanceState); 
    Xamarin.Essentials.Platform.Init(this, savedInstanceState); 
    // Set our view from the "main" layout resource 
    LinearLayout layout = new LinearLayout(this); 
    layout.Orientation = Orientation.Vertical; 
    layout.SetBackgroundColor(Color.White); 
    viewModel = new ViewModel(); 
    sfgrid = new SfDataGrid(this); 
    sfgrid.ItemsSource = viewModel.DataTable; 
    sfgrid.AutoGenerateColumns = false; 
    sfgrid.AllowEditing = true; 
    sfgrid.SelectionMode = SelectionMode.Single; 
    sfgrid.NavigationMode = NavigationMode.Cell; 
    sfgrid.RowHeight = 50; 
 
    var Column = new GridTextColumn(); 
    Column.MappingName = "Name"; 
    Column.HeaderText = "Caption"; 
    Column.UserCellType = typeof(CustomCell); 
    Column.TextMargin = 2; 
 
    sfgrid.Columns.Add(Column); 
 
    sfgrid.CurrentCellBeginEdit += Sfgrid_CurrentCellBeginEdit; 
    sfgrid.CurrentCellEndEdit += Sfgrid_CurrentCellEndEdit; 
 
    layout.AddView(sfgrid); 
    SetContentView(layout); 
} 
We have prepared simple sample based on you requirement and you can download the same using the following link, 
Sample Link: Sample 
Please let us know if you would require any further assistance on this. 
Regards, 
Chandrasekar Sampathkumar 


Marked as answer
Loader.
Up arrow icon