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

how to rebind a detailtable on rowdrop ?

6 Answers 212 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mac
Top achievements
Rank 1
mac asked on 15 Oct 2008, 08:48 PM
hi. Using the drag and drop method... which is awesome. i can't get the detail table where i dropped my rows onto to rebind though.
scenario: two grids, Radgrid2 drops onto Radgrid1 which has a detailTables hierarchy. I am using the method to only allow for one detail table to be open at a time. user can drop either into the detail or straight onto the master.
I am calling detailTables(0).rebind()  at the end of my insert, but that isn't firing. however if I rebind the whole grid it works?
mac




Protected Sub RadGrid1_ItemCommand(ByVal source As ObjectByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand  
        If e.CommandName = RadGrid.ExpandCollapseCommandName Then 
            Dim item As GridItem  
            For Each item In e.Item.OwnerTableView.Items  
                If item.Expanded AndAlso Not item Is e.Item Then 
                    item.Expanded = False 
                End If 
            Next item  
        End If 
    End Sub 
 
    Protected Sub RadGrid1_DetailTableDataBind(ByVal source As ObjectByVal e As Telerik.Web.UI.GridDetailTableDataBindEventArgs) Handles RadGrid1.DetailTableDataBind  
        msg.Text = e.DetailTableView.ParentItem.GetDataKeyValue("costcentre").ToString  
    End Sub 
 
    Protected Sub RadGrid2_RowDrop(ByVal sender As ObjectByVal e As Telerik.Web.UI.GridDragDropEventArgs) Handles RadGrid2.RowDrop  
        Dim dest As String = "" 
        Dim empid As String = e.DraggedItems.Item(0).GetDataKeyValue("Emp_id")  
        If e.DestDataItem.GetDataKeyValue("costcentre") IsNot Nothing Then 
            dest = e.DestDataItem.GetDataKeyValue("costcentre")  
        Else 
            dest = msg.Text ' in the event that the user has opened the detailtable(0)  
        End If 
        If dest IsNot Nothing Then 
            For i As Integer = 0 To e.DraggedItems.Count - 1  
                'insert the items  
                functions.nonqry(ConnStrings.ConnectionStrings, "insert into account (name,accountno) values ('" & dest & "','" & e.DraggedItems.Item(i).GetDataKeyValue("Emp_id") & "')")  
            Next 
        End If 
        Literal1.Text = "CC = " & dest & " " & Date.Now & empid & "     " & e.DestinationGrid.UniqueID.ToString  
        'update the detail table  
        RadGrid1.MasterTableView.DetailTables(0).Rebind()  
 
    End Sub 
    <div> 
         <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Conn %>" 
             SelectCommand="SELECT distinct  [Cost_centre]+ '-' + [Site] as costcentre,  [ID] FROM [tbl_delegate]">  
         </asp:SqlDataSource> 
         <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:Conn %>" 
             SelectCommand="SELECT [name] AS costcentre , accountNo as  Emp_id    
             FROM dbo.account WHERE (name = @CostCentre)"> 
             <SelectParameters> 
                 <asp:ControlParameter ControlID="RadGrid1" Name="CostCentre" PropertyName="SelectedValue" /> 
             </SelectParameters> 
         </asp:SqlDataSource><asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:PHCJobPostsConn %>" 
             SelectCommand="Select top 20 Emp_id, EmpFirstName, EmpLastname from tbl_Current_status">  
         </asp:SqlDataSource> 
         <br /> 
         <telerik:RadGrid ID="RadGrid2" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource3" 
             GridLines="None" AllowPaging="True" AllowMultiRowSelection="True" Width="200px">  
             <MasterTableView DataKeyNames="Emp_id" DataSourceID="SqlDataSource3">  
                 <RowIndicatorColumn> 
                     <HeaderStyle Width="20px" /> 
                 </RowIndicatorColumn> 
                 <ExpandCollapseColumn> 
                     <HeaderStyle Width="20px" /> 
                 </ExpandCollapseColumn> 
                 <Columns> 
                     <telerik:GridBoundColumn DataField="Emp_id" HeaderText="Emp_id" ReadOnly="True" SortExpression="Emp_id" 
                         UniqueName="Emp_id">  
                     </telerik:GridBoundColumn> 
                     <telerik:GridBoundColumn DataField="EmpFirstName" HeaderText="EmpFirstName" SortExpression="EmpFirstName" 
                         UniqueName="EmpFirstName">  
                     </telerik:GridBoundColumn> 
                     <telerik:GridBoundColumn DataField="EmpLastname" HeaderText="EmpLastname" SortExpression="EmpLastname" 
                         UniqueName="EmpLastname">  
                     </telerik:GridBoundColumn> 
                 </Columns> 
             </MasterTableView> 
             <ClientSettings AllowRowsDragDrop="True">  
                 <Selecting AllowRowSelect="True" EnableDragToSelectRows="False" /> 
             </ClientSettings> 
             <FilterMenu EnableTheming="True">  
                 <CollapseAnimation Duration="200" Type="OutQuint" /> 
             </FilterMenu> 
         </telerik:RadGrid><br /> 
         <br /> 
         <br /> 
         <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" 
             GridLines="None" AllowPaging="True" Width="500px">  
             <MasterTableView DataKeyNames="costcentre" DataSourceID="SqlDataSource1">  
                 <DetailTables> 
                     <telerik:GridTableView runat="server"  AutoGenerateColumns="True" DataKeyNames="emp_id" 
                         DataSourceID="SQLDataSource2">  
                         <ParentTableRelation> 
                         <telerik:GridRelationFields DetailKeyField="costcentre" MasterKeyField="costcentre" /> 
                         </ParentTableRelation> 
                         <RowIndicatorColumn> 
                             <HeaderStyle Width="20px" /> 
                         </RowIndicatorColumn> 
                         <ExpandCollapseColumn> 
                                                 <HeaderStyle Width="20px"  /> 
                                              
                         </ExpandCollapseColumn> 
                         <PagerStyle Mode="Slider" /> 
                     </telerik:GridTableView> 
                 </DetailTables> 
                     <Columns> 
                     <telerik:GridBoundColumn DataField="Costcentre" HeaderText="Cost_centre" SortExpression="Cost_centre" 
                         UniqueName="Cost_centre">  
                     </telerik:GridBoundColumn> 
                                         <telerik:GridBoundColumn DataField="ID" DataType="System.Int32" HeaderText="ID" ReadOnly="True" 
                         SortExpression="ID" UniqueName="ID">  
                     </telerik:GridBoundColumn> 
                 </Columns> 
                   
             </MasterTableView> 
               
             <FilterMenu EnableTheming="True">  
                 <CollapseAnimation Duration="200" Type="OutQuint" /> 
             </FilterMenu> 
          
               
         </telerik:RadGrid> 
         <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">  
             <AjaxSettings> 
                 <telerik:AjaxSetting AjaxControlID="RadGrid2">  
                     <UpdatedControls> 
                         <telerik:AjaxUpdatedControl ControlID="RadGrid2" /> 
                         <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> 
                         <telerik:AjaxUpdatedControl ControlID="msg" /> 
                         <telerik:AjaxUpdatedControl ControlID="Literal1" /> 
                     </UpdatedControls> 
                 </telerik:AjaxSetting> 
                 <telerik:AjaxSetting AjaxControlID="RadGrid1">  
                     <UpdatedControls> 
                         <telerik:AjaxUpdatedControl ControlID="msg" /> 
                         <telerik:AjaxUpdatedControl ControlID="Literal1" /> 
                     </UpdatedControls> 
                 </telerik:AjaxSetting> 
             </AjaxSettings> 
         </telerik:RadAjaxManager> 
         <br /> 
         <br /> 
         <asp:Literal ID="msg" runat="server"></asp:Literal> 
         <asp:Literal ID="Literal1" runat="server"></asp:Literal></div>  
 

6 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 20 Oct 2008, 08:21 AM
Hello mac,

You may try using the destinationItem's OwnerTableView property in order to access the GridTableView object to which it belongs. Similar to this:

e.DestDataItem.OwnerTableView.Rebind() 

Please give it a try and let us know if this helps.

Sincerely yours,
Rosen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
mac
Top achievements
Rank 1
answered on 20 Oct 2008, 04:14 PM
Good day. Thank you for your reply. The suggested method does work in part. I find that if the nested table has no records, you cannot drag a row into that detail table. You have to instead drag the row into the master table. This causes the table to once again rebind and collapse the opened items. However if the row does happen to have rows already in it, it will refresh the detail table and leave everything else alone. At lease that is what I am finding. 

I wonder if it might be easier to somehow traverse the rows looking for the affected datakeyvalue and upon finding it, just expand the detail. This would solve the issue of dropping items onto the master table as well as onto the detail table at the same time I would think.

thoughts? cheers.
0
Rosen
Telerik team
answered on 21 Oct 2008, 03:33 PM
Hello mac,

Unfortunately this is a limitation of the current items drag&drop functionality implementation. However, our developers have addressed it and such scenarios will be possible with this year's Q3 version of RadControls For ASP.NET AJAX, expected at the beginning of November. Meanwhile I have updated your telerik points for the feedback.

Please excuse us for the temporary inconvenience.

Best regards,
Rosen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Priya
Top achievements
Rank 1
answered on 11 Nov 2008, 11:20 AM
Sir,

I want  to rebind only the detail table of a radgrid while closing the radwindow.no need to rebind parentgrid and also the detailtable should be in expanded mode after this rebind
thanks..
0
Rosen
Telerik team
answered on 12 Nov 2008, 01:21 PM
Hello Priya,

Can you please provide little more details about your scenario and implementation, as I'm not sure I understend the scenario you are describing.

Sincerely yours,
Rosen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Dan
Top achievements
Rank 1
answered on 17 Aug 2010, 12:21 PM
How could I rebind all 3 of the tables on the page after a RowDrop function, if this is possible since they are not all involved in the RowDrop event but he data will chance as a result of a SQL query in the RowDrop event.
Thanks,
Dan
Tags
Grid
Asked by
mac
Top achievements
Rank 1
Answers by
Rosen
Telerik team
mac
Top achievements
Rank 1
Priya
Top achievements
Rank 1
Dan
Top achievements
Rank 1
Share this question
or