Changing datagrid row order

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
jesse
Posts: 205
Joined: Thu Nov 11, 2010 6:32 pm

Changing datagrid row order

Post by jesse » Tue May 31, 2011 3:45 pm

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.
Deving on WinVista Home Prem. SP2 32 bit. Using LiveCode 4.6.1 Pro Build 1392

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Changing datagrid row order

Post by dunbarx » Tue May 31, 2011 5:03 pm

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

jesse
Posts: 205
Joined: Thu Nov 11, 2010 6:32 pm

Re: Changing datagrid row order

Post by jesse » Wed Jun 01, 2011 1:11 am

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
Deving on WinVista Home Prem. SP2 32 bit. Using LiveCode 4.6.1 Pro Build 1392

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: Changing datagrid row order

Post by bn » Wed Jun 01, 2011 8:51 am

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

Post Reply