dg2 row re-ordering
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 931
- Joined: Thu Nov 13, 2008 6:48 am
- Location: London, UK
dg2 row re-ordering
Is there a quick and easy way in LC to tell if a DG2 has had its rows re-ordered? I have a DG2 that currently lets users: add/delete rows, edit rows, and modify widgets and all of these are detectable and can be used to trigger a save to disk (for permanent storage). However, for row re-ordering I have not figured out a way to detect if this has happened and hence the file on disk needs updating, short of saving every time I leave the current card/page. The cost of saving when unnecessary is actually extremely low and goes unnoticed but I was trying to eliminate it anyway.
Thanks
Thanks
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS
Targets: Mac, iOS
Re: dg2 row re-ordering
Hi Mark,
how can your user "re-order" your dg?
No script(s) involved where you can "hook on"?
Best
Klaus
how can your user "re-order" your dg?
No script(s) involved where you can "hook on"?
Best
Klaus
-
- VIP Livecode Opensource Backer
- Posts: 9578
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: dg2 row re-ordering
Hi.
Save the order, or the entire order "history", in a custom property. Then you can restore it at will, anywhere in the list. This begs the issue of the user changing the contents, as opposed to the line order. You have to watch how and when you update that history.
Craig
Save the order, or the entire order "history", in a custom property. Then you can restore it at will, anywhere in the list. This begs the issue of the user changing the contents, as opposed to the line order. You have to watch how and when you update that history.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 931
- Joined: Thu Nov 13, 2008 6:48 am
- Location: London, UK
Re: dg2 row re-ordering
Hi Klaus, in the new dg2 there is a control you can enable on the right side of the DG that allows re-ordering rows (it is part of dgEditMode in DG2). However, I don't see anyway to actually be notified that a re-ordering has taken place. There are no api's to this function that I can see. I could spin my own but frankly, there are more downsides than upsides. What I do now is just save the whole dg out to disk in the correct order and load it back in the same order. That takes about 1/10 of a second ie. not really noticeable.
Mark
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS
Targets: Mac, iOS
-
- VIP Livecode Opensource Backer
- Posts: 931
- Joined: Thu Nov 13, 2008 6:48 am
- Location: London, UK
Re: dg2 row re-ordering
Hi Craig,dunbarx wrote: ↑Sat Jan 09, 2021 6:58 pmSave the order, or the entire order "history", in a custom property. Then you can restore it at will, anywhere in the list. This begs the issue of the user changing the contents, as opposed to the line order. You have to watch how and when you update that history.
Craig
That's more or less what I do now (to an sqlite file instead of custom property). At present if you add or edit records I update the file in real time. I was concerned that might be noticeable or indicate a lag (so it was not in the original design), but it turns out it's so fast its no problem at all. When I add new records I put the RecNo from the sqlite file in the DG. Later, for individual record edits, I can issue an update for that one record by RecNo, so it's direct and fast. The design at present has the disk file mirroring the dg in all situations except re-ordering rows. For that I just flush the whole dg to disk when the user leaves the "page". Again, very quick so not really a downside other than it's unnecessary if no re-ordering has occurred.
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS
Targets: Mac, iOS
Re: dg2 row re-ordering
ah, I see.marksmithhfx wrote: ↑Tue Jan 12, 2021 3:00 pmHi Klaus, in the new dg2 there is a control you can enable on the right side of the DG that allows re-ordering rows (it is part of dgEditMode in DG2)...
Yes, there is no API for this so I would save my data "prophylacticly" after each:
Code: Select all
...
set the dgEditMode of group "your dg here" to false
## Write back to disk...
...
Best
Klaus