Page 1 of 1
Moving lines in a datagrid
Posted: Tue Mar 21, 2017 6:38 pm
by DavJans
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
Re: Moving lines in a datagrid
Posted: Tue Mar 21, 2017 6:57 pm
by DavJans
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
Re: Moving lines in a datagrid
Posted: Tue Mar 21, 2017 7:10 pm
by DavJans
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?
Re: Moving lines in a datagrid
Posted: Tue Mar 21, 2017 7:56 pm
by Klaus
Hi DavJans,
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
Best
Klaus
Re: Moving lines in a datagrid
Posted: Wed Mar 22, 2017 5:17 pm
by DavJans
Thank you Klaus, you are the best
