dragdrop row from dw_1 overwriting dw_2 row

I am trying to dragdrop a selected row from dw_1 into dw_2 by overwriting a highlighted row in dw_2.  Basically, user clicks a row in dw_1 and drags the mouse over to dw_2 and highlights a row in dw_2 and unclicks.  This would take the row value from dw_1 and overwrite the highlighted row value in dw_2 without inserting a new row.

Example:
dw_1        dw_2
one         one
two         two
three       three
four        four

User drags value three from dw_1 over to dw_2 and overwrites two:
dw_1        dw_2
one         one
two         three (used to be two)
three       three
four        four

Thanks for any guidance you may be able to provide.
LVL 1
the_balkAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
BhattiConnect With a Mentor Commented:
Hello the_balk,

The following script I set before a year for some in expert-exchange, but this script if some one want to scroll with the same datawindow.

If you will see it carefully, you can find your solution. Please look this script carefully and if you need further explaination let me know.



Instance variable il_currentrow, il_row and il_checkrow

=============================================================
************************
clicked Event of dw_1
************************

IF row > 0 then
   il_row = row
   selectRow(0, false)
   selectrow(row, true)
    this.Drag(Begin!)
end if

****************************
DragDrop Event dw_1
****************************

dw_1.drag(End!)


if il_row > row then dw_1.RowsMove(il_row, il_row, Primary!, dw_1, row , Primary!)
if il_row < row then dw_1.RowsMove(il_row, il_row, Primary!, dw_1, row + 1, Primary!)

selectrow(0, false)
selectrow(row, true)

//or you can adjust with selectrow(row - 1, true) and so on
//row you can adjust yourself where you want to paste.

*****************************************************
Scrollvertical Event may you not need but leaving it
*****************************************************

string ls_lastrow

ls_lastrow = dw_1.Object.Datawindow.LastRowOnPage
il_flag = integer(ls_lastrow)

RETURN 0

**********************************
Dragwithin Event dw_2
**********************************

long ll_row

st_1.Text = string(il_flag)
il_currentrow = row
if row = 0 then selectrow(1, true)    
if row > il_flag - 2 then
  il_currentrow++
  scrolltorow(il_currentrow)
  st_2.text = string(ll_row)
else
  if il_currentrow > 0 then
      il_currentrow = il_currentrow - 1
      scrolltorow(il_currentrow)
  end if
end if
if dwo.name = 'datawindow' then
  selectrow(0, false)
else
  selectrow(0, false)
  selectrow(row, true)
end if
=============================================================

Please let me know if success/failer results.

Best regards


Bhatti
0
 
the_balkAuthor Commented:
Thanks Bhatti!

I inserted your code and with a little tinkering and the addition of setitem code in the dragdrop event, it works perfectly.

Again, thank you for your time and help.
0
All Courses

From novice to tech pro — start learning today.