Page 1 of 1

Changing datagrid row order

Posted: Tue May 31, 2011 3:45 pm
by jesse
How would I attempt to change the order of a row in a datagrid?

Example: I have a list of items that are populated from a database. Lets say I want to change
the order of them so they display in the exact order I want them on the datagrid. I would like
to do this by selecting the row and pressing down the CONTROL and arrow up/down key.

How could I accomplish something like this? My long term goal is to have a field in database
that controls the display order so I can save this ordering change on a more permanent basis
so next time the datagrid loads it will be in the order expected.

Re: Changing datagrid row order

Posted: Tue May 31, 2011 5:03 pm
by dunbarx
Couldn't you get the dgText, maybe with the dgHilitedLines property, switch the row data, and reset the dgText?

It would be much cooler to be able to drag and drop entire rows. I do this with list fields all the time, but never in a DG.

Craig Newman

Re: Changing datagrid row order

Posted: Wed Jun 01, 2011 1:11 am
by jesse
Drag and drop would be great but I guess thats not possible. Any suggestions what I would use to trigger the re-order?
I tried the code below assuming I would hold down the F10 and double click at the same time
but it didn't work apparently. I never got by answer F10.

Code: Select all

on mousedoubledown
   if keyNo = '65479' then

      answer "F10"
   else
      answer "Nope"
      end if
end mousedoubledown

Re: Changing datagrid row order

Posted: Wed Jun 01, 2011 8:51 am
by bn
Hi Gery,

try this:

Code: Select all

on mousedoubledown
     if the altkey  is down then
            answer "AltKey"
      else
            answer "Nope"
         end if
end mousedoubledown
The way you tried to query the functionKey does not work. You get the number only if you watch for rawKey events.

Code: Select all

on rawKeyDown theKey
   put theKey && the milliseconds into field 1
end rawKeyDown
You can only query the modifier keys for being "down" in a on mouseWhatever handler.

Kind regards

Bernd