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

RadWindow doesnot fire on single click for the first time

1 Answer 22 Views
Window
This is a migrated thread and some comments may be shown as answers.
Cheryl
Top achievements
Rank 1
Cheryl asked on 27 Aug 2015, 09:28 AM

Hi,

 I have a RadWindow which opens up on the click event of a rad button present in each row of a RadGrid.

The RadWindow doesn't open on the single click for the first time (it takes double click for the first time) and opens in single click the next time.

Please see the code below and not sure if I am missing some thing.

Thanks!

ASPX:

<telerik:GridTemplateColumn HeaderText="Order Now" AllowFiltering="false" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="10%" ItemStyle-Width="10%">
                            <ItemTemplate>
                                <asp:LinkButton ID="gvlnkbtnViewMenu" runat="server" Text="View" CommandName="VIEW" CausesValidation="false" ToolTip="Open PDF" ForeColor="#B72B3C" Font-Bold="false" Font-Underline="true"></asp:LinkButton>
                            </ItemTemplate>

</telerik:GridTemplateColumn>‚Äč

  <telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="true">
            <Windows>
               <telerik:RadWindow ID="UserListDialog" runat="server" Modal="true" OnClientShow="setWindowsize" VisibleStatusbar="false" Title="" >
                </telerik:RadWindow>
            </Windows>
        </telerik:RadWindowManager>

 function ShowEditForm(id, rowIndex) {
                var grid = $find("<%= radGridPrintStatus.ClientID %>");
                    var rowControl = grid.get_masterTableView().get_dataItems()[rowIndex].get_element();
                    grid.get_masterTableView().selectItem(rowControl, true);
                    window.radopen("Viewer.aspx?ID=" + id, "UserListDialog");
                    return false;
             }

ASPX.CS :

 protected void radGridPrintStatus_ItemCommand(object sender, GridCommandEventArgs e)
        {
            if (e.CommandName.ToUpper().Equals("VIEW"))
            {
                GridDataItem item = (GridDataItem)e.Item;
                string rowId = item["MenuId"].Text;
                LinkButton editLink = (LinkButton)item.FindControl("gvlnkbtnViewMenu");
                editLink.Attributes["href"] = "javascript:void(0);";
                editLink.Attributes["onclick"] = String.Format("return ShowEditForm('{0}','{1}');", rowId, e.Item.ItemIndex);              
            }

1 Answer, 1 is accepted

Sort by
0
Accepted
Danail Vasilev
Telerik team
answered on 31 Aug 2015, 12:23 PM
Hi Cheryl,

This behavior is expected - you are attaching to the ItemCommand event where is performed the actual client click handler attachment, so that on the second click the handler itself will be fired.

I would suggest that you attach the client click handler on other event, for example the ItemCreated one:

ASPX:
<telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
<telerik:RadGrid ID="radGridPrintStatus" runat="server" OnNeedDataSource="radGridPrintStatus_NeedDataSource" OnItemCreated="radGridPrintStatus_ItemCreated">
    <MasterTableView>
        <Columns>
            <telerik:GridTemplateColumn HeaderText="Order Now" AllowFiltering="false" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="10%" ItemStyle-Width="10%">
                <ItemTemplate>
                    <asp:LinkButton ID="gvlnkbtnViewMenu" runat="server" Text="View" CommandName="VIEW" CausesValidation="false" ToolTip="Open PDF" ForeColor="#B72B3C" Font-Bold="false" Font-Underline="true"></asp:LinkButton>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>
 
 
<telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="true">
    <Windows>
        <telerik:RadWindow ID="UserListDialog" runat="server" Modal="true" OnClientShow="setWindowsize" VisibleStatusbar="false" Title="">
        </telerik:RadWindow>
    </Windows>
</telerik:RadWindowManager>
<script>
    function setWindowsize() {
 
    }
 
    function ShowEditForm(id, rowIndex) {
        var grid = $find("<%= radGridPrintStatus.ClientID %>");
        var rowControl = grid.get_masterTableView().get_dataItems()[rowIndex].get_element();
        grid.get_masterTableView().selectItem(rowControl, true);
        window.radopen("Viewer.aspx?ID=" + id, "UserListDialog");
        return false;
    }
</script>

C#:
protected void radGridPrintStatus_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
    (sender as RadGrid).DataSource = GetData();
}
 
protected DataTable GetData()
{
    DataTable dt = new DataTable();
 
    dt.Columns.Add("MenuId", typeof(int));
    dt.Columns.Add("SellQuantity", typeof(int));
    dt.Columns.Add("SellDate", typeof(DateTime));
 
    dt.Rows.Add(1, 2, new DateTime(2011, 06, 12));
    dt.Rows.Add(2, 5, new DateTime(2011, 12, 12));
    dt.Rows.Add(3, 6, new DateTime(2012, 06, 17));
    dt.Rows.Add(4, 4, new DateTime(2012, 09, 18));
    dt.Rows.Add(5, 7, new DateTime(2013, 03, 18));
 
    return dt;
}
 
protected void radGridPrintStatus_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem item = (GridDataItem)e.Item;
        string rowId = item["MenuId"].Text;
        LinkButton editLink = (LinkButton)item.FindControl("gvlnkbtnViewMenu");
        editLink.Attributes["href"] = "javascript:void(0);";
        editLink.Attributes["onclick"] = String.Format("return ShowEditForm('{0}','{1}');", rowId, e.Item.ItemIndex);
    }
}



Regards,
Danail Vasilev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Window
Asked by
Cheryl
Top achievements
Rank 1
Answers by
Danail Vasilev
Telerik team
Share this question
or