click event

I have a SfCheckBox in a SfDataGrid column template. Can I capture the click event (when the user clicks on the SfCheckBox) not the StateChanged event?



7 Replies

NY Nirmalkumar Yuvaraj Syncfusion Team April 12, 2024 12:14 PM UTC

Hi Gerardo

  

In MAUI, by default, the touch is passed to the element that is on top. In this scenario, the sfcheckbox is positioned above the template column. Consequently, capturing the click event when the user clicks on the SfCheckBox isn't feasible. The event will be processed by the SfCheckBox itself rather than the datagrid.


Regards,

Nirmalkumar



GL Gerardo Lopez Ruiz April 12, 2024 02:33 PM UTC

Is there a way to differentiate between whether the StateChanged event is triggered by the data being loaded or by the user's click? The StateChanged is triggered whenever I load the data into the datagrid and there is a state change.



TP Tamilarasan Paranthaman Syncfusion Team April 15, 2024 04:33 PM UTC

Hi Gerardo,


At the initial data loading, the StateChanged event of the SfCheckBox loaded in the DataGrid template column will be triggered. Additionally, this event will also be triggered whenever you tap on the SfCheckBox. Currently, there is no built-in way to differentiate whether the event is triggered due to data loading or a click event.


Could you please confirm whether you expect the StateChanged event of the SfCheckBox to be called only when the checkbox is clicked, and not during data loading? Additionally, please provide clearer details about your requirement. This will help us better understand your needs and provide you with an appropriate solution as quickly as possible.


Regards,

Tamilarasan


Attachment: Output_24bf87e0.zip


GL Gerardo Lopez Ruiz April 22, 2024 08:56 PM UTC

In the video the event is triggered when the data is loaded at the beginning (once for each grid record), and the same event is triggered when the user clicks on the check. I want to execute an action only when the change is triggered when the user checks.



TP Tamilarasan Paranthaman Syncfusion Team April 23, 2024 04:22 PM UTC

Gerardo,

When loading the SfCheckBox in the template column, it's important to note that the StateChanged event may be triggered during the initial loading process. While we haven't handled this event specifically on our end, you can still achieve your desired functionality using the SfCheckBox.IsLoaded property.


Within the StateChanged event handler, you can access this property to determine whether the SfCheckBox has finished loading or not. When IsLoaded is true, it indicates that the control has completed its initialization, allowing you to perform your specific actions accordingly.


For your convenience, we have attached a simple sample code snippet below for reference. Please review it for a better understanding:


        private void SfCheckBox_StateChanged(object sender, Syncfusion.Maui.Buttons.StateChangedEventArgs e)

        {

            if(sender is SfCheckBox checkBox && checkBox.IsLoaded)

            {

                // You can identify it by using the [SfCheckBox.IsLoaded] property.

                // The [SfCheckBox.IsLoaded] property returns true

                // if the SfCheckBox is loaded and ready for user interaction; otherwise, it returns false.

                //

                // Do your action here when the checkbox state is changed through user interaction.

 

 

            }

        }


Regards,

Tamilarasan


Attachment: Sample_d05ea84c.zip


GL Gerardo Lopez Ruiz April 23, 2024 04:43 PM UTC

It works thank you!



TP Tamilarasan Paranthaman Syncfusion Team April 24, 2024 11:36 AM UTC

Gerardo,


We are glad that the provided response helps you. Please let us know if you require further assistance. As always, we are happy to help you out.


Regards,

Tamilarasan


Note: If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.


Loader.
Up arrow icon