Unplanned
Last Updated: 23 May 2023 09:32 by Russ

args.get_eventTargetElement() in OnRequestStart event returns null when Paging the Grid initiates an AjaxRequest via AjaxManager

How do I determine if the event target is a RadGrid?

The following code leads to a JavaScript error

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" ClientEvents-OnRequestStart="requestStart">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadGrid1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
            </UpdatedControls>
        </telerik:AjaxSetting>

JavaScript

function requestStart(sender, args) {
    var target = args.get_eventTargetElement();
    if (target.className.indexOf("RadGrid") > -1) {
        // RadGrid control
    }
}

Unplanned
Last Updated: 26 May 2021 19:46 by ADMIN
Created by: Joel
Comments: 0
Category: Ajax
Type: Bug Report
0
I have a RadGrid with several thousand elements on it. In attempting to improve performance, the Visual Studio profiler informed me that it spent more than half of the request in PopulatePlainPanels checking whether something was in a list. (see attached before.png)

I changed the type of the variable plainPanelsClientIDs in RadAjaxControl.cs to be a HashSet<string> instead of a List<string>. As a knock-on effect, I had to import System.Linq into RadAjaxManager.cs to get the .toArray() call to work.

The result in the attached after.png shows the percentage of execution time dropped from 55% to 3%.

I'd appreciate it if the team would evaluate this change for inclusion in future releases.

Note 1: I have not done extensive testing on this, so I don't know what might break. The variable isn't referenced much, so the only thing I'm suspicious of is reflection, which I didn't check for and don't expect.
Note 2: If importing Linq is undesirable, a more manual conversion to an array can be done pretty easily.
Note 3: plainPanelsClientIDs is .add() 'ed to in two places, and both check for membership before being called. This shouldn't be necessary for a HashSet, which simply doesn't add if it's there. This seems a very minor improvement, but I didn't actually try it yet.