Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
90
Drag and drop or other means of changing the sequence/position of items in a webgrid hierarchy
posted

Hi there, We want, as explained in a previous post, to implement an outliner with columns using the xamwebgrid.  Your support people have told us that drag and drop is not currently available or built-in for the records/rows in the webgrid.  We have requested this feature for inclusion in future versions of webgrid, therefore.  In the meantime, can you suggest any other method for including either drag-and-drop or another means for moving the position of the records/rows, both on their own level and up or down the hierarchy.  This capability is currently available in your tree but not, as noted, in the webgrid.

Thanks in advance for any help on this, Eric

  • 40030
    Suggested Answer
    Offline posted

    Hi Eric, 

    Our support team is correct, in that the XamWebGrid doesn't currently offer this feature. 

    If you wanted, you could probably achieve this using 3 of the xamWebGrid's event, MouseLeftButtonDown, MouseLeftButtonUp, and MouseMove. 

    I haven't attempted this, however it should be possible. 

    You'd want to use the e.OriginalSource paramter of these events to see where you are, and see if you're over a CellControlBase. From this, you can get access to the row. 

    ((CellControlBase)e.OriginalSource).Cell.Row

    In MouseLeftButtonDown,  for dragging, you can create a System.Window.Controls.Primitives.Popup control, and use a WriteableBitmap of the row you're dragging. Be sure to call this.DataGrid1.CaptureMouse(), so nothing else inteferes with the mouse while you're dragging. 

    In MouseMove, you would then move the popup to the position of the mouse. 

    Then in MouseLeftButtonUp, you'd see if you're over a row, and that its a different row than the one you're dragging. 

    Hope this helps in someway, 

    -SteveZ