This is a migrated thread and some comments may be shown as answers.

RadGrid Client Side Header Click Event

7 Answers 281 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 01 Oct 2014, 02:28 PM
Is there a client side event for when the header is clicked in the RadGrid?  I am seeing that there is a ColumnClicked event, but I need an event just prior to that being fired since the CellSelecting event fires before the ColumnClicked event and the CellSelecting event does not appear to indicate whether the header was clicked or not that I have been able to see.

7 Answers, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 06 Oct 2014, 10:44 AM
Hello David,

Generally there is no exposed event to which you can subscribe that would fit the requirements. However you can attach a mousedown handler to the grid and check if a header is click using the following code.

ASPX:
<telerik:RadGrid ID="RadGrid1" onmousedown="onGridMouseDown(this,event);">
        </telerik:RadGrid>

JavaScript:
function onGridMouseDown(s, e) {
                if (e.target.className.indexOf("rgHeader") !== -1) {
                    //header was clicked
                }
            }


Regards,
Angel Petrov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
David
Top achievements
Rank 1
answered on 07 Oct 2014, 02:03 PM
When I add this code to my .aspx page and run it I get the following error: Parser Error Message: Type 'Telerik.Web.UI.GridClientEvents' does not have a public property named 'OnMouseDown'.

I also do not see an OnMouseDown event under RadGrid ClientEvents
0
Angel Petrov
Telerik team
answered on 10 Oct 2014, 07:28 AM
Hello David,

The illustrated behavior is expected. The grid does not have an OnMouseDown client event exposed. If you examine the code provided in my previous post you will notice that the handler is attached directly in the markup(an approach also illustrated here). Considering the aforementioned I recommend applying the same principle to the real application and testing it again.

Regards,
Angel Petrov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Jonathan
Top achievements
Rank 1
answered on 15 Dec 2018, 05:17 PM
I know this is a really old post, but maybe this will help someone.  I needed to do the same thing, so I just use a mouse click event to check whether the e.location was within the area of the header I was wanting to assign an event to.
0
John
Top achievements
Rank 1
answered on 20 Nov 2019, 09:41 PM
Sorry, this is reviving old post. This works for me but also seems to cancel everything else I would expect. For example, when I click on the header to sort, the onGridMouseDown javascript executes but the sort never happens. And there is no postback or calling of NeedDataSource. It's also trapping when I click on the filter dropdown and executing the same js but the filtering never happens either. any ideas?
0
Jonathan
Top achievements
Rank 1
answered on 20 Nov 2019, 11:05 PM

If (e.locaction < RadGridView1.GridViewElement.TitleLabelElement.Size.Height)

     'perform action(s);
0
Eyup
Telerik team
answered on 21 Nov 2019, 08:10 AM

Hello,

 

I am also posting the reply here so it could be helpful to other developers as well:

The proper way to achieve this requirement is to use the built-in event handlers and the API of the grid - OnUserAction or OnCommand:
https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/client-side-programming/events/onuseraction

Hope this helps.

 

Regards,
Eyup
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
David
Top achievements
Rank 1
Jonathan
Top achievements
Rank 1
John
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or