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

[Solved] ClientSelectColumn select all the detail table row when modal popup show on Link button click event

3 Answers 200 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sree
Top achievements
Rank 1
Sree asked on 02 Apr 2009, 12:27 PM
I have a Rad Grid in my web site,here the rad grid is ajaxified using the radajax panel,inside the rad grid i have detail tables,when i select the detail tables clientselectcolumn and then click the link button inside the detail tables,the ajax modal popup is show,at that time all details tables clientselectcolumn are selected so,it will select all the detail tables record
 <DetailTables> 
                                <telerik:GridTableView NoDetailRecordsText="Contact(s) not exist to this company.." 
                                    NoMasterRecordsText="Contact(s) not exist to this company.." CommandItemDisplay="Top" 
                                    AllowSorting="False" AllowPaging="false" Name="Contacts"  ClientDataKeyNames="ContactId" DataKeyNames="ContactId,CompanyId" Width="100%" 
                                    runat="server">  
                                    <ParentTableRelation> 
                                        <telerik:GridRelationFields DetailKeyField="CompanyId" MasterKeyField="CompanyId" /> 
                                    </ParentTableRelation> 
                                    <CommandItemTemplate> 
                                        <div style="padding-top: 7px; padding-bottom: 7px;">  
                                            <asp:LinkButton ID="lnkAddNew" runat="server" CommandName="AddNewContact">  
                                        <img style="border:0px;vertical-align:middle;" alt="Add Contact" src="Images/addnew.gif" /> Add New</asp:LinkButton>&nbsp;&nbsp;&nbsp;  
                                            <asp:LinkButton ID="Lnkdeleteselected" runat="server" CommandName="DeleteSelectedContact" 
                                                CausesValidation="false">  
                                        <img style="border:0px;vertical-align:middle;"  alt="Delete Selected Contacts" src="Images/delete.gif" /> Delete Selected</asp:LinkButton> 
                                            &nbsp;&nbsp;&nbsp;  
                                            <asp:LinkButton ID="LnkPrintContact" Visible="false" runat="server" CommandName="PrintContact">  
                                        <img style="border:0px;vertical-align:middle;" alt="Print" src="Images/print.gif" /> Print</asp:LinkButton> 
                                        </div> 
                                    </CommandItemTemplate> 
                                    <Columns> 
                                        <telerik:GridBoundColumn DataField="CompanyId" DataType="System.Int32" HeaderText="CompanyId" 
                                            ReadOnly="True" SortExpression="CompanyId" UniqueName="CompanyId" Visible="False">  
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridBoundColumn DataField="ContactId" DataType="System.Int32" HeaderText="ContactId" 
                                            ReadOnly="True" SortExpression="ContactId" UniqueName="ContactId" Visible="False">  
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridClientSelectColumn  Reorderable="False" UniqueName="ClientDetailSelectColumn">  
                                            <HeaderStyle Width="20px"></HeaderStyle> 
                                        </telerik:GridClientSelectColumn> 
                                        <telerik:GridTemplateColumn SortExpression="ContactName" GroupByExpression="ContactName ContactName Group By ContactName" 
                                            HeaderText="Contact Name" UniqueName="ContactName">  
                                            <ItemTemplate> 
                                                <asp:LinkButton ID="lnkContactName" runat="server" CommandName="ContactName" Text='<%#DataBinder.Eval(Container.DataItem, "ContactName")%>'></asp:LinkButton> 
                                            </ItemTemplate> 
                                            <ItemStyle Width="22%" Wrap="False" /> 
                                        </telerik:GridTemplateColumn> 
                                        <telerik:GridBoundColumn DataField="FullAddress" HeaderText="Address" SortExpression="FullAddress" 
                                            UniqueName="Address">  
                                            <ItemStyle Width="15%" Wrap="False" /> 
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridTemplateColumn SortExpression="PhoneNumber" GroupByExpression="PhoneNumber PhoneNumber Group By PhoneNumber" 
                                            HeaderText="Phone Number" UniqueName="TemplateColumn">  
                                            <ItemTemplate> 
                                                <table> 
                                                    <tr> 
                                                        <td style="border: none;">  
                                                            <asp:Image ImageUrl="~/Images/telephone.gif" Visible="false" ID="ImgPhone1" runat="server" /></td>  
                                                        <td style="border: none;">  
                                                            <asp:Label ID="LblPhone1" Visible="false" runat="server"></asp:Label></td>  
                                                    </tr> 
                                                    <tr> 
                                                        <td style="border: none;">  
                                                            <asp:Image ImageUrl="~/Images/telephone.gif" Visible="false" ID="ImgPhone2" runat="server" /></td>  
                                                        <td style="border: none;">  
                                                            <asp:Label ID="LblPhone2" Visible="false" runat="server"></asp:Label></td>  
                                                    </tr> 
                                                    <tr> 
                                                        <td style="border: none;">  
                                                            <asp:Image ImageUrl="~/Images/telephone.gif" Visible="false" ID="ImgPhone3" runat="server" /></td>  
                                                        <td style="border: none;">  
                                                            <asp:Label ID="LblPhone3" Visible="false" runat="server"></asp:Label></td>  
                                                    </tr> 
                                                </table> 
                                            </ItemTemplate> 
                                            <ItemStyle Width="20%" Wrap="False" /> 
                                        </telerik:GridTemplateColumn> 
                                        <telerik:GridTemplateColumn SortExpression="Fax" GroupByExpression="Fax Fax Group By Fax" 
                                            HeaderText="Fax Number" UniqueName="TemplateColumn1">  
                                            <ItemTemplate> 
                                                <table style="border: none;">  
                                                    <tr> 
                                                        <td style="border: none;">  
                                                            <asp:Image ImageUrl="~/Images/fax.gif" Visible="false" ID="ImgFax1" runat="server" /></td>  
                                                        <td style="border: none;">  
                                                            <asp:Label ID="LblFax1" Visible="false" runat="server"></asp:Label></td>  
                                                    </tr> 
                                                    <tr> 
                                                        <td style="border: none;">  
                                                            <asp:Image ImageUrl="~/Images/fax.gif" Visible="false" ID="ImgFax2" runat="server" /></td>  
                                                        <td style="border: none;">  
                                                            <asp:Label ID="LblFax2" Visible="false" runat="server"></asp:Label></td>  
                                                    </tr> 
                                                    <tr> 
                                                        <td style="border: none;">  
                                                            <asp:Image ImageUrl="~/Images/fax.gif" Visible="false" ID="ImgFax3" runat="server" /></td>  
                                                        <td style="border: none;">  
                                                            <asp:Label ID="LblFax3" Visible="false" runat="server"></asp:Label></td>  
                                                    </tr> 
                                                </table> 
                                            </ItemTemplate> 
                                            <ItemStyle Width="20%" Wrap="False" /> 
                                        </telerik:GridTemplateColumn> 
                                        <telerik:GridTemplateColumn SortExpression="Email" GroupByExpression="Email Email Group By Email" 
                                            HeaderText="Email" UniqueName="TemplateColumn2">  
                                            <ItemTemplate> 
                                                <table> 
                                                    <tr> 
                                                        <td style="border: none;">  
                                                            <asp:Image ImageUrl="~/Images/email.gif" Visible="false" ID="ImgEmail1" runat="server" /></td>  
                                                        <td style="border: none;">  
                                                            <asp:LinkButton ID="LnkEmail1" CommandName="Email1" Visible="false" runat="server"></asp:LinkButton> 
                                                        </td> 
                                                    </tr> 
                                                    <tr> 
                                                        <td style="border: none;">  
                                                            <asp:Image ImageUrl="~/Images/email.gif" Visible="false" ID="ImgEmail2" runat="server" /></td>  
                                                        <td style="border: none;">  
                                                            <asp:LinkButton ID="LnkEmail2" CommandName="Email2" Visible="false" runat="server"></asp:LinkButton></td>  
                                                    </tr> 
                                                    <tr> 
                                                        <td style="border: none;">  
                                                            <asp:Image Visible="false" ImageUrl="~/Images/email.gif" ID="ImgEmail3" runat="server" /></td>  
                                                        <td style="border: none;">  
                                                            <a><asp:LinkButton Visible="false" CommandName="Email3"  ID="LnkEmail3" runat="server"></asp:LinkButton></a></td> 
                                                    </tr> 
                                                </table> 
                                            </ItemTemplate> 
                                            <ItemStyle Width="35%" Wrap="False" /> 
                                        </telerik:GridTemplateColumn> 
                                        <telerik:GridBoundColumn Visible="False" DataField="Status" HeaderText="Status" SortExpression="Status" 
                                            UniqueName="Status">  
                                            <ItemStyle Wrap="False" /> 
                                        </telerik:GridBoundColumn> 
                                        <telerik:GridTemplateColumn Groupable="False" UniqueName="TemplateColumn3">  
                                            <ItemTemplate> 
                                                <asp:LinkButton ID="LnkEditDetail" runat="server" CommandName="EditContact">  
                                                    <asp:Image ID="ImgEdit" runat="server" ImageUrl="~/Images/edit.gif" ToolTip="Edit contact " 
                                                        AlternateText="Edit contact" /> 
                                                </asp:LinkButton>&nbsp;&nbsp;&nbsp;  
                                                <asp:LinkButton ID="LnkDeleteDetail" runat="server" CommandName="DeleteContact">  
                                                    <asp:Image ID="ImgDelete" runat="server" ImageUrl="~/Images/delete.gif" ToolTip="Delete contact" 
                                                        AlternateText="Delete contact" /> 
                                                </asp:LinkButton> 
                                            </ItemTemplate> 
                                            <ItemStyle Wrap="False" HorizontalAlign="Center" /> 
                                        </telerik:GridTemplateColumn> 
                                    </Columns> 
                                    <ExpandCollapseColumn> 
                                        <HeaderStyle Width="20px" /> 
                                    </ExpandCollapseColumn> 
                                    <RowIndicatorColumn> 
                                        <HeaderStyle Width="20px" /> 
                                    </RowIndicatorColumn> 
                                </telerik:GridTableView> 
                            </DetailTables> 

3 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 06 Apr 2009, 04:58 PM
Hi Sree,

May I ask you to provide additional information about your scenario? Could you explain in steps what should be the required behavior? Thus I will do my best to help you further.

Regards,
Georgi Krustev
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Sree
Top achievements
Rank 1
answered on 20 Apr 2009, 04:58 AM
Hi George,
    i have the heirarchical grid,in the detail table we are using the clientselectcolumn to select the item in the detail table, when we select one or two item in the detail table, and then click the linkbutton in the command item template of the detail to table to delete the selected item in the detail table, at that that time ajax modal popup comes to ask the question '' Are you sure to delete the selected item?'' simultaneously all the item in the detail table are selected .... this is the situation,so when i click the 'yes' button in the modal popup all the item in the detail table get deleted,i am not able to delete the selected item in the detail table
0
Georgi Krustev
Telerik team
answered on 23 Apr 2009, 01:41 PM
Hello Sree,

Unfortunately I could not reproduce this issue. I created a test project in my attempt to recreate the abnormality explained so far. I used the latest official build of RadControls. I attached my sample web site project to this forum thread.

The important point here is that you need to delete only the rows which are marked as selected. Here is a code snippet from the attached project which shows how to achieve this:

    protected void rgTestWithDifferentBindWay_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.CommandName == "DeleteAllSelected")  
        { 
            using (DataClassesDataContext nw = new DataClassesDataContext()) 
            { 
                List<Order> listForDeleting = new List<Order>(); 
                foreach (GridDataItem item in e.Item.OwnerTableView.Items) 
                { 
                    if (item.Selected) 
                    { 
                        int id = Convert.ToInt32(e.Item.OwnerTableView.DataKeyValues[item.ItemIndex]["OrderID"]); 
                        listForDeleting.Add(nw.Orders.Single(o => o.OrderID == id)); 
                    } 
                } 
                nw.Orders.DeleteAllOnSubmit(listForDeleting); 
                nw.SubmitChanges(); 
            } 
            e.Item.OwnerTableView.Rebind(); 
        } 
    } 

Greetings,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Sree
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Sree
Top achievements
Rank 1
Share this question
or