We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

GridCheckBoxColumn dont raise RowValidating / RowValidated events

Thread ID:

Created:

Updated:

Platform:

Replies:

121528 Dec 24,2015 12:30 PM Mar 8,2016 06:28 AM WPF 5
loading
Tags: GridDataControl
Marcio Maciel
Asked On December 24, 2015 12:30 PM

Hi Syncfusion Team

Alls columns type, like ComboBox and Text, raise RowValidating / RowValidated events when user move to other row in grid, except GridCheckBoxColumn.

Scenario:
WPF .Net 4.6.1, sfDataGrid 13.3.0.18 Community Edition, ItemsSource = ObservableCollection, GridValidationMode = InEdit, EditTrigger = OnTap, NavigationMode = Cell, SelectionMode = Extended

Steps:
- User enter in any text column, sfDataGrid raise CellBeginEdit event
- User change value, raise multiple CellValueChanged events
- User move to another row, raising CellValidating, CellValidated, RowValidating, RowValidated and CellEndEdit events

In RowValidated I can save changes in SQLite database.

- User click in checkbox column, sfDataGrid raise CellValueChanged event
- User move to another row (click in RowHeader or click in checkbox in other row) and sfDataGrid dont raise RowValidating / RowValidated

My ugly turn around:

 - SelectionMode = Single
 - private bool anyChanges = false in window scope;
 - anyChanges = true in CurrentCellDropDownSelectionChanged and CurrentCellValueChanged events;
 - if(anyChanges) {...} in SelectionChanging event to save changes in SQLite database


Sorry my poor english, and hugs from Brasil.

Marcio Maciel


Jai Ganesh S [Syncfusion]
Replied On December 28, 2015 06:44 AM

Hi Marcio,


Thank you for using Syncfusion Products.


We regret to inform you that, the Events like BeginEdit, EndEdit, CellValidating and RowValidating will not be triggered for GridCheckBoxColumn in SfDataGrid. In GridCheckBoxColumn, we loaded the EditElement directly hence the above events are not supported in GridCheckBoxColumn. However we have prepared the work around for firing the Validated event like the below code example,


Code Example[C#]:



 
void DataGrid_CurrentCellValueChanged(object sender, CurrentCellValueChangedEventArgs args)
        {

            int rowIndex = args.RowColumnIndex.RowIndex;
            int columnIndex =this.DataGrid.ResolveToGridVisibleColumnIndex(args.RowColumnIndex.ColumnIndex);

            //We are enabling the RowValidating event if the changes happen in GridCheckBoxColumn
            if (this.DataGrid.Columns[columnIndex].CellType == "CheckBox")
            {
                this.DataGrid.GetValidationHelper().SetCurrentRowValidated(false);
            }
     
        }
 


Here we have setting the IsCurrentRowValidated as false using ValidationHelper.SetCurrentRowValidated()
method.



Sample Location: http://www.syncfusion.com/downloads/support/directtrac/148928/ze/ValidateTestSfGrid201200701

 
Please let me know if you have any other concerns.


Regards,
Jai Ganesh S



dsfakjhasdfkbn
Replied On March 2, 2016 08:24 AM

Hi

I could not use this workaround (manually calling SetCurrentRowValidated(false)) because the event DataGrid_CurrentCellValueChanged does not fire for GridComboBoxColumn and also not for a ComboBoxAdv in a DataTemplate.
My environment is slightly different: WPF .Net 4.5.1, sfDataGrid  13.4451.0.58, 13.4.0.58 Community Edition

I attached a sample solution derived from your works (zip file provided by Jai Ganesh S, see below)
Could please someone look into this? Thanks.



Attachment: ValidateTestSfGrid201200701with_CheckBoxAndComboBoxAdv_e6868e84.zip

Srinivasan Vasu [Syncfusion]
Replied On March 3, 2016 11:02 PM

Hi Marcio,


We regret to inform you that, the CurrentCellValueChanged event will not be trigger for GridComboxBoxColumn and GridTemplateColumn in SfDataGrid.  For GridComboBoxColumn, you have to use CurrentCellDropDownSelectionChanged event for notify the value changes and for GridTemplateColumn you have to use separate event as per the control that you have loaded in it. For an example, you have loaded the ComboBoxAdv control where you have you can use SelectionChanged event to notify the selection changed. Please refer the below code example,


C#



GridComboBoxColumn
:

using Syncfusion.UI.Xaml.Grid.Helpers;


void DataGrid_CurrentCellDropDownSelectionChanged(object sender, CurrentCellDropDownSelectionChangedEventArgs args)

        {

            int rowIndex = args.RowColumnIndex.RowIndex;

            int columnIndex = this.DataGrid.ResolveToGridVisibleColumnIndex(args.RowColumnIndex.ColumnIndex);

           //We are enabling the RowValidating event if the changes happen in GridCheckBoxColumn

            if (this.DataGrid.Columns[columnIndex].CellType == "ComboxBox")

            {

                this.DataGrid.GetValidationHelper().SetCurrentRowValidated(false);

            }       

        }          




GridCheckBoxColumn
:

using Syncfusion.UI.Xaml.Grid.Helpers;


void DataGrid_CurrentCellValueChanged(object sender, CurrentCellValueChangedEventArgs args)

        {

int rowIndex = args.RowColumnIndex.RowIndex;

            int columnIndex = this.DataGrid.ResolveToGridVisibleColumnIndex(args.RowColumnIndex.ColumnIndex);          

            //We are enabling the RowValidating event if the changes happen in GridCheckBoxColumn

            if (this.DataGrid.Columns[columnIndex].CellType == "CheckBox")

            {

                this.DataGrid.GetValidationHelper().SetCurrentRowValidated(false);

            }        

}



ComboxAdv
in GridTemplateColumn:

  using Syncfusion.UI.Xaml.Grid.Helpers;


  private void MyComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)

        {                   

                this.DataGrid.GetValidationHelper().SetCurrentRowValidated(false);              

        }            





We have prepared a sample as per your requirement and you can download the same from the below location,


Sample : http://www.syncfusion.com/downloads/support/forum/121528/ze/ValidateTest329851855



Regards,

Srinivasan


dsfakjhasdfkbn
Replied On March 7, 2016 12:08 PM

Hi Vasu

Thank you very much for the update. With these workarounds RowValidating will be fired for all in this thread mentioned controls.
In the zip, the file MainWindow.xaml.cs has a typo "ComboxBox" instead of "ComboBox".

Thanks again

Srinivasan Vasu [Syncfusion]
Replied On March 8, 2016 06:28 AM

Hi Marcio,

Sorry for the inconvenience

We have corrected the mistake “ComboxBox” instead of “ComboBox”. We have attached modified sample. Please find the sample from the below location.

Sample:
http://www.syncfusion.com/downloads/support/forum/121528/ze/ValidateTest-911450465
Regards,
Srinivasan
 



CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;