4 Answers, 1 is accepted
GridClientSelectColumn displays a check box control for each cell in the column. If you want to show LinkButton/PushButton for selecting rows, then use GridButtonColumn with its CommandName set to "Select" or "Deselect":
aspx:
| <Columns> |
| <telerik:GridButtonColumn Text="Select" CommandName="Select"></telerik:GridButtonColumn> |
| <telerik:GridButtonColumn Text="Deselect" CommandName="Deselect"></telerik:GridButtonColumn> |
| </Columns> |
Regards,
Shinu.
I continue to get the postback event fired even though I've tried to disable it. My radgrids ClientEvents.OnRowSelected event is not being triggerd with the above suggestion. I need the functionality of the GridClientSelectColumn as a linkbutton (text apposed to checkbox) and possibly an Icon. If I use a GridClientSelectColumn w/ checkboxes everything works as expected only using the undesired checkboxes.
I looked at doing it as a TemplateColumn, but I still need the clientside row selection Object that exists when using GridClientSelectColumn.
How do I get a linkbutton to fire the ClientEvents.OnRowSelected event ?
Telerik Answer & Sample Code
set the onCommand event in the clientevents section of the radgrid to "RadGridCommand" and then use the following :
| <telerik:GridButtonColumn Text="Select" CommandName="Select" /> |
| <script type="text/javascript"> |
| function RadGridCommand(sender, args) |
| { |
| if (args.get_commandName() == "Delete") |
| { |
| args.set_cancel(true); |
| //item index |
| var itemIndex = args.get_commandArgument(); |
| } |
| if (args.get_commandName() == "Select") |
| { |
| args.set_cancel(true); |
| sender.get_masterTableView() |
| sender.get_masterTableView().selectItem(args.get_commandArgument()); |
| alert(args.get_commandArgument()); |
| } |
| } |
| </script> |
Jeremy,
What I ended up doing is, add a template coulmn with a label control and it's text set to "Select". Then I defined a CssClass for this label to appear like a link button. That solved my purpose. I can click the label control and still fire ClientEvents.RowSelectedEvent.
Here is what I have in aspx file for RadGrid ....
<Columns>
<telerik:GridTemplateColumn>
<ItemTemplate>
<asp:Label ID="lblSelect" runat="server" Text="Select" ToolTip="Select a Contact" CssClass="action-link" />
</ItemTemplate>
</telerik:GridTemplateColumn>
<!-- Other columns Here -->
</Columns>
And here is my style definition for "action-link" ...
.action-link
{
margin: 2px 5px 2px 5px;
padding: 2px 5px 2px 5px;
width: 100px;
text-align: center;
text-decoration: underline;
font-family: Verdana, Arial, Geneva, Helvetica, sans-serif;
font-weight: normal;
font-size: 11px;
color: Black;
cursor: hand;
}
You may want to change the font settings according to your project.
Hope this helps.