Unplanned
Last Updated: 18 Jul 2023 07:31 by ADMIN
Thiyagarajan
Created on: 11 Jul 2023 09:37
Category: Grid
Type: Bug Report
0
Grid triggers the rowClick when clicking on the AutoCompleteBox causing the page to do a PostBack

When EnablePostBackOnRowClick="true" and clicking on the RadAutoCompleteBox inside the EditItemTemplate the Grid will make a PostBack.

This issue does not happen with other elements (span, input, button, etc).

1 comment
ADMIN
Attila Antal
Posted on: 18 Jul 2023 07:31

Hello Thiyagarajan,

Thank you for reporting this issue. After checking the source code we found that the Grid's internal logic does not prevent the click event for the RadAutoCompleteBox, hence triggering a PostBack when that is clicked.

Workaround

The following script overrides the Grid's internal logic and includes the RadAutoCompletBox in the condition to prevent PostBack when the element is clicked.

You can place this script anywhere on the page, but only after the ScriptManager declaration.

<script>
    (function () {
        try {
            // store the original function in a variable
            var originalClick = Telerik.Web.UI.GridSelection.prototype._click;

            // override the original function
            Telerik.Web.UI.GridSelection.prototype._click = function (e) {
                var el = (e.target) ? e.target : e.srcElement;

                // if autocompletebox do not trigger the RowClick
                if (el.classList.contains('racTokenList') || el.classList.contains('RadAutoCompleteBox')) { return; }

                // Call the original function
                originalClick.call(this, e);
            }
        } catch (e) {
            // oh no, the Telerik.Web.UI.GridSelection is not defined.
        }
    })();
</script>

 

Regards,
Attila Antal
Progress Telerik

Heads up! Telerik UI for ASP.NET AJAX versions for .NET 3.5 and 4.0 are retired. Progress will continue shipping assemblies compatible with .NET 4.5 and later. See whether this affects your apps in this article.