I would like to reorder data in a Data Grid. It it possible, ideally for me, to select for example line 4 and then push a button to move it up to line 3 and have line 3 move down to line 4? (or click and drag? I'm not too worried about this and am probably just dreaming).
I would like to do this so that later I can save that new order into our mysql server as the order that it will populate in later when the data is recalled
Moving lines in a datagrid
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Moving lines in a datagrid
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här
Re: Moving lines in a datagrid
this works 
on mouseUp
put the dgDataOfLine[3] of group "DataGridLotList" into tLineData
put the dgDataOfLine[2] of group "DataGridLotList" into tOtherLineData
set the dgDataOfLine[2] of group "DataGridLotList" to tLineData
set the dgDataOfLine[3] of group "DataGridLotList" to tOtherLineData
end mouseUp

on mouseUp
put the dgDataOfLine[3] of group "DataGridLotList" into tLineData
put the dgDataOfLine[2] of group "DataGridLotList" into tOtherLineData
set the dgDataOfLine[2] of group "DataGridLotList" to tLineData
set the dgDataOfLine[3] of group "DataGridLotList" to tOtherLineData
end mouseUp
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här
Re: Moving lines in a datagrid
To move Down I got this.
global sortLineNumber
global totalNumOfLines
on mouseUp
if sortLineNumber < totalNumOfLines then
put sortLineNumber + 1 into otherLineNumber
put the dgDataOfLine[sortLineNumber] of group "DataGridLotList" into tLineData
put the dgDataOfLine[otherLineNumber] of group "DataGridLotList" into tOtherLineData
set the dgDataOfLine[otherLineNumber] of group "DataGridLotList" to tLineData
set the dgDataOfLine[sortLineNumber] of group "DataGridLotList" to tOtherLineData
put sortLineNumber + 1 into sortLineNumber
end if
end mouseUp
To move up I got this.
global sortLineNumber
on mouseUp
if sortLineNumber > 1 then
put sortLineNumber - 1 into otherLineNumber
put the dgDataOfLine[sortLineNumber] of group "DataGridLotList" into tLineData
put the dgDataOfLine[otherLineNumber] of group "DataGridLotList" into tOtherLineData
set the dgDataOfLine[otherLineNumber] of group "DataGridLotList" to tLineData
set the dgDataOfLine[sortLineNumber] of group "DataGridLotList" to tOtherLineData
put sortLineNumber - 1 into sortLineNumber
end if
end mouseUp
Is there a way I haven't found yet to have the highlight also move with the line?
global sortLineNumber
global totalNumOfLines
on mouseUp
if sortLineNumber < totalNumOfLines then
put sortLineNumber + 1 into otherLineNumber
put the dgDataOfLine[sortLineNumber] of group "DataGridLotList" into tLineData
put the dgDataOfLine[otherLineNumber] of group "DataGridLotList" into tOtherLineData
set the dgDataOfLine[otherLineNumber] of group "DataGridLotList" to tLineData
set the dgDataOfLine[sortLineNumber] of group "DataGridLotList" to tOtherLineData
put sortLineNumber + 1 into sortLineNumber
end if
end mouseUp
To move up I got this.
global sortLineNumber
on mouseUp
if sortLineNumber > 1 then
put sortLineNumber - 1 into otherLineNumber
put the dgDataOfLine[sortLineNumber] of group "DataGridLotList" into tLineData
put the dgDataOfLine[otherLineNumber] of group "DataGridLotList" into tOtherLineData
set the dgDataOfLine[otherLineNumber] of group "DataGridLotList" to tLineData
set the dgDataOfLine[sortLineNumber] of group "DataGridLotList" to tOtherLineData
put sortLineNumber - 1 into sortLineNumber
end if
end mouseUp
Is there a way I haven't found yet to have the highlight also move with the line?
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här
Re: Moving lines in a datagrid
Hi DavJans,
if the currently hilited line = sortLineNumber, then add this at the end of your script:
Best
Klaus
if the currently hilited line = sortLineNumber, then add this at the end of your script:
Code: Select all
...
set the dghilitedlines of group "DataGridLotList" to otherLineNumber
end mouseup
Klaus
Re: Moving lines in a datagrid
Thank you Klaus, you are the best 

"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här