May 19, 2009

telerik radGrid - select a row without using select links / buttons and allow it to postback

I was in a need to enable the user to select a row by clicking on it (not by clicking on some Select link or image or button).
I also wanted this click to postback so I can do some processing on the server side.

It is not so hard to achieve, but I was puzzled for quite a while so I decided to share it.

In order to allow the grid to select a row by clicking on the row, you need to add the ClientSettings to the radGrid and configure the following:

<ClientSettings EnablePostBackOnRowClick="true">
<Selecting AllowRowSelect="true" />
</
ClientSettings>

AllowRowSelect is the property to enable / disable row selection.
EnablePostBackOnRowClick will tell the grid to post back on row selection. It is really strightforward when you think of it, but checking so much properties / section to find out if the radGrid has the one you need is annoying sometimes.

Anyway, I am glad that the radGrid has this functionality built-in.

2 comments:

Anonymous said...

Hi, how could I get the datakey of the selected row and pass it to the server?,

Anonymous said...

Thank u, you saved my day, documentation is stupid in that aspect.