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
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 Object, ByVal 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 Object, ByVal 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 Object, ByVal 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> |