双击rad网格在某些情况下不起作用

时间:2015-06-24 04:27:46

标签: c# asp.net visual-studio-2013 telerik telerik-grid

我有一个radgrid,我想要点击并双击它。我使用了一个javascript代码来点击双击但在某些情况下它会返回“RowClick”命令到ItemCommand事件! 我有以下代码:

 <telerik:RadGrid ID="RadGrid_Mails" OnDataBound="RadGrid_Mails_DataBound" SkinID="<% $Resources:Strings,SkinID %>"
    OnSortCommand="RadGrid_Mails_SortCommand" AllowAutomaticDeletes="True" Width="99.8%"
    AllowSorting="True" AutoGenerateColumns="False" AllowPaging="True"
    runat="server" ShowFooter="True" AllowMultiRowSelection="True"
    AllowFilteringByColumn="True" Height="550px" HorizontalAlign="Center"
    ClientSettings-EnablePostBackOnRowClick="true"
    OnNeedDataSource="RadGrid_Mails_NeedDataSource"
    OnPreRender="RadGrid_Mails_PreRender"
    OnSelectedIndexChanged="RadGrid_Mails_SelectedIndexChanged"
    OnItemCommand="RadGrid_Mails_ItemCommand">
    <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
    <MasterTableView Width="100%" GridLines="None" CommandItemDisplay="Top" AllowSorting="true" AllowPaging="true"
    HorizontalAlign="Center" ClientDataKeyNames="Mokatebeh_ID"
    AllowAutomaticInserts="True">
        <CommandItemTemplate>
         .....
            <ClientSettings>
                <Scrolling AllowScroll="false" />
                <ClientEvents OnRowDblClick="RowDblClickMails" />
                <Selecting AllowRowSelect="True" EnableDragToSelectRows="false"></Selecting>
            </ClientSettings>

</telerik:RadGrid>

javascript代码:

var isDoubleClickMails = false;
            var clickHandlerMails = null;
            var ClickedIndexMails = null; 
        function RowDblClickMails(sender, args) {
                ClickedIndexMails = args._itemIndexHierarchical; // newly added
                isDoubleClickMails = true;
                if (clickHandlerMails) {
                    window.clearTimeout(clickHandlerMails);
                    clickHandlerMails = null;
                }
                clickHandlerMails = window.setTimeout(ActualClickMails, 200);
            }

            function ActualClickMails() {
                if (isDoubleClickMails) {
                    var grid = $find("<%=RadGrid_Mails.ClientID %>");
                    if (grid) {
                        var MasterTable = grid.get_masterTableView();
                        var Rows = MasterTable.get_dataItems();
                        for (var i = 0; i < Rows.length; i++) {
                            var row = Rows[i];
                            if (ClickedIndexMails != null && ClickedIndexMails == i) { // newly added
                                MasterTable.fireCommand("RowDblClickMails", ClickedIndexMails); // newly added
                            } // newly added
                        }
                    }
                }
           }
代码背后的代码:

if (e.CommandName == "RowDblClickMails")
{ 
    //do something
}

0 个答案:

没有答案