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

Lock a row from being dropped to via drag and drop

1 Answer 52 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 26 Aug 2011, 04:46 PM
I have a postion table that I drag and drop personnel to positions, however they want the ability to lock out positions.  So what I do is put a number in a field in the db that pulls into the grid.  I turn this number invisible for the column but now how can I lock out the row from being dropped to in the drag and drop event.  Only using code behind so i am using the rowDrop event.
Protected Sub myGridSoldier_RowDrop(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridDragDropEventArgs) Handles myGridSoldier.RowDrop
  
        If e.DestDataItem.OwnerTableView.ClientID = myGridPositions.MasterTableView.ClientID Then
            For i As Integer = 0 To e.DraggedItems.Count - 1
                Dim SSN As String = e.DraggedItems(i).GetDataKeyValue("SSN")
                Dim PositionId As Integer = e.DestDataItem.GetDataKeyValue("intPositionId")
  
                HFSSN.Value = SSN
                HFPosition.Value = PositionId
  
                FillInfo(SSN, PositionId)
  
                pnlSoldierInfo_POP.Show()
            Next
        End If
    End Sub

1 Answer, 1 is accepted

Sort by
0
Mira
Telerik team
answered on 31 Aug 2011, 12:42 PM
Hello Kevin,

In order to implement the desired functionality, I recommend that you use the OnRowDropping event. In its event handler you can identify the target element on which the dragged grid record is dropped. If this element does not meet your criteria for acceptable target, cancel the operation by setting args.set_cancel(true) where args is the second argument passed to the OnRowDropping handler. Additionally, to determine the destination element or set it explicitly use the get_destinationHtmlElement() and set_destinationHtmlElement() properties that can be accessed through the args argument in the handler.
Please examine the Drag and Drop of Grid Items help topic for additional information.

I hope this helps.

All the best,
Mira
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
Grid
Asked by
Kevin
Top achievements
Rank 1
Answers by
Mira
Telerik team
Share this question
or