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

Opening a record when clicking on an columns of that record

5 Answers 57 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ashvin
Top achievements
Rank 1
Ashvin asked on 01 Aug 2008, 01:42 PM
Hi Telerik Team,

I have a grid with all Bound Columns in it. I want to open a record on a mouse click of any columns of that record. How do I do that?

Regards
Ashvin

5 Answers, 1 is accepted

Sort by
0
Sean
Top achievements
Rank 2
answered on 01 Aug 2008, 03:42 PM

I would do it using the ClientSettings-ClientEvents-OnRowClick event, like:

<
script>
function RowClick(sender, eventArgs) {
alert(
"Click on row: " + eventArgs.get_itemIndexHierarchical());
eventArgs.set_cancel(true);
}

</script>

<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" AllowSorting="True"BorderStyle="None" Skin="Telerik" GridLines="None" OnNeedDataSource="radData_NeedDataSource">
<MasterTableView>
<RowIndicatorColumn Visible="False">
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
<ExpandCollapseColumn Visible="False" Resizable="False">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
<HeaderStyle HorizontalAlign="Center" />
<Columns>
<telerik:GridTemplateColumn ItemStyle-Width="150px" HeaderStyle-Width="150px" HeaderText="Name" UniqueName="Name" SortExpression="EntityName">
<ItemTemplate>
<!-- SOME CONTENT -->
</ItemTemplate>
<HeaderStyle Width="150px"></HeaderStyle>
<ItemStyle Width="150px"></ItemStyle>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
<ClientSettings EnableRowHoverStyle="true">
<Selecting AllowRowSelect="true" />
<ClientEvents OnRowClick="RowClick"/>
</ClientSettings>
</telerik:RadGrid>

Sean~

0
Evgeny
Top achievements
Rank 1
answered on 21 Nov 2008, 06:49 PM
Hi,

It seems like OnRowClick is not a cancellable event anymore, at least in Q3 release. trying to call aventArgs.set_cancel(true) raises JS error "Object doesn't support this property or method", while OnRowSelecting and other cancellable events work properly. Am I doing something wrong?

If I'm correct, how can I cancel firing the event ItemCommand on server side, having a combination of 

EnablePostBackOnRowClick

 

="True" in RadGrid client settings, and any client-side event on the grid?

0
Yavor
Telerik team
answered on 24 Nov 2008, 06:17 AM
Hi Evgeny,

You can use the rowClick to open a new window to the new location, or the details on that record. A similar approach is shown in the following example.
I hope this helps.

All the best,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Evgeny
Top achievements
Rank 1
answered on 24 Nov 2008, 06:30 AM
Hi,

Thanks for the example, but actually it's not what I need.

I have grid without editing capabilities (i.e. no edit/delete buttons inside the grid). When user clicks on a row, I need to show confirmation dialog and then let it perform callback to the server side or not depending on user's choice.

For now, I implemented it using OnRowSelecting on client and standard javascript cofirmation dialog, it works but this is not exactly what I need. An ideal way for me would be still having cancellable OnRowClick event (just like it is described in all your documentation and forum answers on similar questions), or any possible workaround simulating such behaviour. Also no page refreshes possible - only Ajax calls. Any ideas?

As an outstanding question - I can't understand why you changed this approach and made OnRowCLick not cancellable?
0
Yavor
Telerik team
answered on 26 Nov 2008, 11:31 AM
Hi Evgeny,

The approach is achievable in the following manner - when clicking on the row, you can use a RadConfirm. The RadConfirm will return a result, depending on the user's choice - true or false. Then, depending on the result, you can either take no action, or make a callBack (AjaxRequest) to the server. Hence, you do not need to cancel the client side event.
I hope this suggestion helps.

Greetings,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Ashvin
Top achievements
Rank 1
Answers by
Sean
Top achievements
Rank 2
Evgeny
Top achievements
Rank 1
Yavor
Telerik team
Share this question
or