RadGrid Client Side Header Click Event

5 posts, 0 answers
  1. David
    David avatar
    11 posts
    Member since:
    Jun 2014

    Posted 01 Oct 2014 Link to this post

    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.

  2. Angel Petrov
    Admin
    Angel Petrov avatar
    1076 posts

    Posted 06 Oct 2014 Link to this post

    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.

     
  3. David
    David avatar
    11 posts
    Member since:
    Jun 2014

    Posted 07 Oct 2014 in reply to Angel Petrov Link to this post

    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
  4. Angel Petrov
    Admin
    Angel Petrov avatar
    1076 posts

    Posted 10 Oct 2014 Link to this post

    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.

     
  5. Jonathan
    Jonathan avatar
    1 posts
    Member since:
    Oct 2018

    Posted 15 Dec 2018 in reply to David Link to this post

    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.
Back to Top