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. Image for the cookie policy date

In Grid Edit mode

Hi,

the edit mode of the current record will automatically lost when another record is selected. How can we avoid this? Is is possible to leave the edit mode by save or cancel button?

regards
Tuong Trinh



3 Replies

BM Bala Murugan A.S Syncfusion Team October 15, 2013 12:51 PM UTC

Hi Tuong Trinh,

 

Thanks for using Syncfusion Products.

 

We glad to let you know that we have created a workaround for your requirement. Please refer the below code snippets.

 

[Default.aspx]

 

<script type="text/javascript">

                    $(document).ready(function () {

                        window.Temp_OnGRMouseUp = window.EG_OnGRMouseUp; //store this event in temp

                        window.EG_OnGRMouseUp = Custom_OnGRMouseUp; //define custom client side method to prevent selection and saving records on other row selection

 

                    });

                    function Custom_OnGRMouseUp(evt) {

                        var src = GetEventSrcElement(evt);

                        if (src.tagName == "TD") {

                            var td = GetGTCell(src);

                            if (td == null) {

                                return;

                            }

                            var tr = td.parentNode;

                            var gridObj = GetEGridObj(tr);

                            var isCurRow = gridObj.IsCurrentRow(tr);

                            if (gridObj.GetState() == "Edit") {

                                if (!isCurRow) {

                                    gridObj.AllowClientSideSelection = false; //prevent client side selection

                                    evt.cancelBubble = true;

                                    return;

                                }

                            }

                            else {

                                gridObj.AllowClientSideSelection = true;

                                window.Temp_OnGRMouseUp(evt);

                            }

                        }

                    }

 

                </script>

The above solution can be achieved by overriding the EG_OnGRMouseUp client side method and preventing the client side record selections with postback.

 

For your convenience, we have prepared a simple sample to demonstrate this and the same can be downloaded from the below link.

 

Sample: PreventSelection.zip

 

Please let us know if you have any concerns.

 

Regards,

Balamurugan A.S



TT Tuong Trinh October 15, 2013 03:33 PM UTC

Hi Balamurugan A.S,

this workaround is fantastic. 

Thank you for helping out.

regards
Tuong Trinh


BM Bala Murugan A.S Syncfusion Team October 16, 2013 11:59 AM UTC

Hi Tuong Trinh,

Thanks for your update.

Please get back to us if you need any further assistance.

Regards,
Balamurugan A.S

Loader.
Live Chat Icon For mobile
Up arrow icon