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

Call serverside event OnItemDblClick

3 Answers 104 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 14 Mar 2011, 10:05 AM
Hello,

I have a treelist which shows an overview of all contentpages. I have implemented a editbutton in the treelisttemplate which will navigate the user to another page to edit the specific contentpage. I want to achieve the same result when the user doubleclick on a specific row in the treelist. I have achieved in with a single click (ClientSettings-AllowPostBackOnItemClick="true") but is this also possible on a doubleclick event (client)

Thanks

Patrick

3 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 14 Mar 2011, 04:52 PM
Hello Patrick,

You can setup RadTreeList to fire the ItemClick command on double click instead of single click. To do that:

1. Remove EnablePostBackOnItemClick to prevent postback from single clicks.
2. Attach to the client-side OnItemDblClick event of RadTreeList:

<telerik:RadTreeList>
    <ClientSettings>
        <ClientEvents OnItemDblClick="itemDblClick" />
    </ClientSettings>
</telerik:RadTreeList>

3. Use RadTreeList's client-side API to fire an ItemClick command:

function itemDblClick(sender, args)
{
    sender.fireCommand("ItemClick", args.get_item().get_displayIndex());
}

Note the above fireCommand function call. I pass the command name that I need the server-side ItemCommand event handler to fire for and I also pass the display index of my target item. Without the latter RadTreeList won't know which item fired the command. The result - I get RadTreeList's server-side ItemClick command firing on double click.

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!
0
Erik
Top achievements
Rank 2
answered on 06 Apr 2013, 09:27 PM
Hi All,

@Telerik: Since I found tons of forum, blog and code library info for controls for using DblClick, why not implement this by standard, optional?

To elaborate a bit more and to make the "RAD" come through for this matter; my solution:

ASPX
<telerik:RadScriptBlock runat="server" ID="RadScriptBlock1">
    <script type="text/javascript">
        // <![CDATA[        //
        function OnRadTreeList_Main_RowDblClick(sender, eventArgs) {
            //alert("RowDblClicked:" + eventArgs.get_item().get_dataKeyValue("ContactId"));
            sender.fireCommand("ItemDblClick", eventArgs.get_item().get_displayIndex());
        }
        // ]]>
    </script>
</telerik:RadScriptBlock>
<telerik:RadTreeList ID="RadTreeList_Main" ClientDataKeyNames="ContactId" DataKeyNames="ContactId" ParentDataKeyNames="ParentContactId" AutoGenerateColumns="false" ShowTreeLines="false" AllowSorting="True" GridLines="Vertical" runat="server" ItemStyle-Wrap="False">
    <Columns>
        ...
    </Columns>
    <ClientSettings AllowPostBackOnItemClick="false" >
        <ClientEvents OnItemDblClick="OnRadTreeList_Main_RowDblClick" />
    </ClientSettings>
</telerik:RadTreeList>

VB Code

Private Sub RadTreeList_Main_ItemCommand(sender As Object, e As Telerik.Web.UI.TreeListCommandEventArgs) Handles RadTreeList_Main.ItemCommand
    Try
        If (e.CommandName & "").Trim.ToLower = "ItemDblClick".ToLower Then
            Dim DataItem As TreeListDataItem = CType(e.Item, TreeListDataItem)
            Dim lng_ContactId As Long = DataItem.GetDataKeyValue("ContactId")
            ...
        End If
    Catch ex As Exception
        If Diagnostics.Debugger.IsAttached Then Diagnostics.Debugger.Break()
    End Try
 
End Sub


Erik
0
Maria Ilieva
Telerik team
answered on 10 Apr 2013, 10:54 AM
Hi Erik,

Thank you for sharing your solution.I'm sure it will be very useful for other users trying to implement the same functionality.
Also you could log your request into our feedback portal below so that other users could vote for it and increase its priority:
http://feedback.telerik.com/project/108

Regards,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
TreeList
Asked by
Patrick
Top achievements
Rank 1
Answers by
Veli
Telerik team
Erik
Top achievements
Rank 2
Maria Ilieva
Telerik team
Share this question
or