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

RadGrid OnRowClick & OnRowDblClick Events

1 Answer 247 Views
Grid
This is a migrated thread and some comments may be shown as answers.
wendy
Top achievements
Rank 1
wendy asked on 21 Sep 2011, 06:16 AM
I have an aspx page that has a RadGrids. I want to perform different operation in clicking and double-clicking the row. I have two client-side events for OnRowClick and OnRowDblClick. But RowClick is always called even I have double-clicking the row. How to make

OnRowDblClick together with OnRowClick ?


 Here are my codes:

 

 

function OnRowClick(sender, eventArgs) {

 

    alert(

 

"Row-Clicking")

 

}

 

 

function RowDoubleClick(sender, eventArgs) {

 

    alert(

 

"Double-clicking")

 

 }

<

 

 

telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" AllowSorting="false"

 

 

 

AllowMultiRowSelection="False" AllowPaging="True" GridLines="Both" ShowGroupPanel="false"

 

 

 

OnItemCommand="RadGrid_ItemCommand" OnNeedDataSource="RadGrid_NeedDataSource"

 

 

 

OnItemDataBound="OnGridItemDataBound">

 

 

 

<PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true"></PagerStyle>

 

 

 

<MasterTableView DataKeyNames="MeterStationNumber" AllowMultiColumnSorting="False">
----

 

 

 

</MasterTableView>

 

<

 

 

ClientSettings AllowDragToGroup="false" EnableRowHoverStyle="true" >

 

 

 

<ClientEvents OnRowDblClick="RowDoubleClick" OnRowClick="OnRowClick"/>

 

 

 

</ClientSettings>

 

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 21 Sep 2011, 07:17 AM
Hello Wendy,

Try the following Javascript by setting a timeout so that we can make both events fire.
JS:
<script type="text/javascript">
var isDoubleClick = false;
var clickHandler = null;
function OnRowClick()
{
 isDoubleClick = false;
 if (clickHandler)
 {
  window.clearTimeout(clickHandler);
  clickHandler = null;
 }
  clickHandler = window.setTimeout(ActualClick, 200);
}
function OnRowDblClick()
{
 isDoubleClick = true;
 if (clickHandler)
 {
  window.clearTimeout(clickHandler);
  clickHandler = null;
 }
  clickHandler = window.setTimeout(ActualClick, 200);
}
function ActualClick()
{
  if (isDoubleClick)
  {
   alert("Double Click");
  }
  else
  {
    alert("Single Click");
  }
}      
</script>

Thanks,
Princy.
Tags
Grid
Asked by
wendy
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or