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

RadGrid Delete Button Not Opening RadWindow

1 Answer 112 Views
Grid
This is a migrated thread and some comments may be shown as answers.
PPI Itdept
Top achievements
Rank 1
PPI Itdept asked on 15 Jul 2008, 09:46 PM
I'm currently changing my code from Q3 2007 to Q1 2008 with RadGrid and have a problem. I created a Delete Column inside the grid and when the user clicks on it is supposed to open the RadWindow but it doesn't. It worked in Q3 2007 but not here. Is there something I'm missing ?

Thanks

<rad:RadCodeBlock ID="RadCodeBlock1" runat="server">  
// ******** Category Functions ********  
            function ShowDeleteCategoryForm(categoryID, productID, rowIndex)  
            {  
                  
                // $find instead of window replaced [] with ()  
                var grid = window["<%= rgCategory.ClientID %>"];  
                 
                var rowControl = grid.MasterTableView.Rows[rowIndex].Control;   
                  
                grid.MasterTableView.SelectRow(rowControl, true);  
                           
                window.radopen("Edit_Product/DeleteCategory.aspx?CategoryID=" + categoryID + "&ProductID=" + productID, "DeleteCategory");  
                return false;   
            }  
function CloseCategory()  
            {  
                // $find instead of window  
                window["<%= rgCategory.ClientID %>"].AjaxRequest('<%= rgCategory.UniqueID %>', 'RebindAndNavigateCategory');  
            }  
 </script> 
        </rad:RadCodeBlock> 
        <asp:ScriptManager ID="ScriptManager1" runat="server">  
        </asp:ScriptManager> 

<rad:RadGrid ID="rgCategory" runat="server" Visible="false" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" BorderWidth="0px" GridLines="None" Skin="Office2007" ShowStatusBar="True" BorderColor="#BFDBFF" Font-Size="8.5pt" Font-Names="Verdana" CellPadding="5" CellSpacing="5" OnItemCreated="rgCategory_ItemCreated">  
                    <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle> 
                        <MasterTableView DataKeyNames="CategoryID,ProductID,SystemID" CommandItemDisplay="Bottom" > 
                          
                            <RowIndicatorColumn Visible="False">  
                                <HeaderStyle Width="20px" /> 
                            </RowIndicatorColumn> 
                            <ExpandCollapseColumn Resizable="False" Visible="False">  
                                <HeaderStyle Width="20px" /> 
                            </ExpandCollapseColumn> 
                          
                            <Columns> 
                                <rad:GridBoundColumn DataField="CategoryID" DataType="System.Int32" SortExpression="CategoryID" UniqueName="CategoryID" HeaderText="CategoryID" Visible="False" /> 
                              
                                <rad:GridBoundColumn DataField="ProductID" DataType="System.Int32" SortExpression="ProductID" UniqueName="ProductID" HeaderText="ProductID" Visible="False" /> 
                                  
                                <rad:GridBoundColumn DataField="SystemID" DataType="System.Int32" SortExpression="SystemID" UniqueName="SystemID" HeaderText="SystemID" Visible="False" /> 
                                                                    
                                <rad:GridBoundColumn DataField="Name" HeaderText="Category" UniqueName="Name">  
                                    <HeaderStyle HorizontalAlign="Center" /> 
                                    <ItemStyle HorizontalAlign="Center" /> 
                                </rad:GridBoundColumn> 
                              
                                <rad:GridBoundColumn DataField="Deleted" HeaderText="Deleted" UniqueName="Deleted" Visible="True">  
                                    <HeaderStyle HorizontalAlign="Center" /> 
                                    <ItemStyle HorizontalAlign="Center" /> 
                                </rad:GridBoundColumn> 
                              
                                <rad:GridBoundColumn DataField="CreatedOn" HeaderText="Created On" UniqueName="CreatedOn">  
                                    <HeaderStyle HorizontalAlign="Center" /> 
                                    <ItemStyle HorizontalAlign="Center" /> 
                                </rad:GridBoundColumn> 
                              
                                <rad:GridBoundColumn DataField="CreatedBy" HeaderText="Created By" UniqueName="CreatedBy">  
                                    <HeaderStyle HorizontalAlign="Center" /> 
                                    <ItemStyle HorizontalAlign="Center" /> 
                                </rad:GridBoundColumn> 
                              
                                <rad:GridBoundColumn DataField="LastModifiedOn" HeaderText="Modified On" UniqueName="LastModifiedOn" Visible="False">  
                                    <HeaderStyle HorizontalAlign="Center" /> 
                                    <ItemStyle HorizontalAlign="Center" /> 
                                </rad:GridBoundColumn> 
                              
                                <rad:GridBoundColumn DataField="LastModifiedBy" HeaderText="Modified By" UniqueName="LastModifiedBy" Visible="False">  
                                    <HeaderStyle HorizontalAlign="Center" /> 
                                    <ItemStyle HorizontalAlign="Center" /> 
                                </rad:GridBoundColumn> 
                                  
                                <rad:GridTemplateColumn UniqueName="TemplateDeleteColumn">  
                                    <ItemTemplate> 
                                        <asp:HyperLink ID="DeleteLink" runat="server">  
                                        <asp:Image ID="DeleteCategory" runat="server" ImageUrl="~/RadControls/Grid/Skins/Delete.gif" AlternateText="Delete Category" /> 
                                        </asp:HyperLink> 
                                    </ItemTemplate> 
                                </rad:GridTemplateColumn> 
                                            
                            </Columns> 
                              
                            <CommandItemTemplate> 
                                <div style="text-align: left ">  
                                    <br /> 
                                    <asp:HyperLink ID="AddLink" runat="server" Visible="false">  
                                    <asp:Image ID="AddRecord1" runat="server" ImageUrl="~/RadControls/Grid/Skins/AddRecord.gif" AlternateText="Add Category" /> 
                                    Add Category</asp:HyperLink> 
                                    <br /><br /> 
                                </div> 
                            </CommandItemTemplate> 
                              
                        </MasterTableView> 
                          
                        <ClientSettings> 
                            <Selecting AllowRowSelect="True" /> 
                        </ClientSettings> 
                          
                </rad:RadGrid> 


 <rad:RadWindowManager ID="RadWindowManager1" runat="server" Skin="Office2007" Behavior="Close">  
           <Windows> 
<rad:RadWindow ID="DeleteCategory" runat="server" Width="450px" Height="180px" Title="Delete" Skin="Office2007" Modal="true" OnClientClose="CloseCategory" /> 
               <rad:RadWindow ID="AddNewCategory" runat="server" Width="755px" Height="600px" Title="Add New" Skin="Office2007" Modal="true" OnClientClose="CloseCategory" /> 
  </Windows> 
       </rad:RadWindowManager>   
        

Here is the code behind

protected void rgCategory_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)  
        {  
            if (e.Item is GridDataItem)  
            {  
                HyperLink deleteLink = e.Item.FindControl("DeleteLink") as HyperLink;  
                deleteLink.Attributes["href"] = "#";  
                deleteLink.Attributes["onclick"] = string.Format("return ShowDeleteCategoryForm('{0}','{1}','{2}');", e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["CategoryID"], e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ProductID"], e.Item.ItemIndex);  
            }  
 
            if (e.Item is GridCommandItem)  
            {  
                  
                HyperLink addLink = e.Item.FindControl("AddLink") as HyperLink;  
                addLink.Visible = true;  
                addLink.Attributes["href"] = "#";  
                addLink.Attributes["onclick"] = string.Format("return ShowInsertCategoryForm('{0}','{1}');", productID, systemID);  
              
            }  
 
        } 

    protected override void RaisePostBackEvent(IPostBackEventHandler sourceControl, string eventArgument)  
        {  
            base.RaisePostBackEvent(sourceControl, eventArgument);  
 
            if (sourceControl is RadGrid)  
            {  
                switch (eventArgument)  
                {  
                    case "RebindAndNavigateCategory":  
                        rgCategory.MasterTableView.SortExpressions.Clear();  
                        rgCategory.MasterTableView.GroupByExpressions.Clear();  
                        rgCategoryrgCategory.MasterTableView.CurrentPageIndex = rgCategory.MasterTableView.PageCount - 1;  
                        rgCategory.Rebind();  
                        break;  
         }  
            }  
 
        } 

1 Answer, 1 is accepted

Sort by
0
PPI Itdept
Top achievements
Rank 1
answered on 15 Jul 2008, 10:26 PM
Tags
Grid
Asked by
PPI Itdept
Top achievements
Rank 1
Answers by
PPI Itdept
Top achievements
Rank 1
Share this question
or