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

Disable Left Click Sort (but keep menu)

1 Answer 74 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Justavian
Top achievements
Rank 1
Justavian asked on 09 Mar 2011, 06:53 PM
I'm interested in shifting the right click column context menu to a left click.  I've gotten this to work by binding to the OnColumnClick event and showing the menu in that way (though i also have to put in a timer and disable closing the menu for a short time - otherwise it shows and immediately hides itself).  However, if the user clicks on the header text itself (rather than just the column background), the grid still wants to sort itself.  Disabling sort fixes that problem, but then it also removes the sort functions from the context menu.

My context menu already has a number of custom elements in it, and i could certainly just add my own custom entries there.  But i figured i would stop in here and see if there's an out of the box way to accomplish this goal.  Can you turn off click to sort, but maintain the menu entries?

-RP

1 Answer, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 15 Mar 2011, 10:52 AM
Hi Justavian,

The approach you have taken is correct. RadGrid does not provide the functionality you need out of the box. You need to continue in the same way. To prevent sorting by clicking on the header cell text ( which is a link button firing sort command), you can take any of 2 approaches:

1. Use server-side code (the PreRender event will do) to find all link buttons in the header cells of the master table and attach the "return false" client click script. Thus, the command attached to the link won't execute.

2. Use client-side code to attach the an onclick  handler that will prevent the default event behavior. The command will be prevented.

The two approaches are equivalent in working, only different on whether you need to use server code or javascript to setup.

Veli
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
Grid
Asked by
Justavian
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or