Page 1 of 1
dg2 row re-ordering
Posted: Sat Jan 09, 2021 1:28 pm
by marksmithhfx
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
Re: dg2 row re-ordering
Posted: Sat Jan 09, 2021 2:24 pm
by Klaus
Hi Mark,
how can your user "re-order" your dg?
No script(s) involved where you can "hook on"?
Best
Klaus
Re: dg2 row re-ordering
Posted: Sat Jan 09, 2021 6:58 pm
by dunbarx
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
Re: dg2 row re-ordering
Posted: Tue Jan 12, 2021 3:00 pm
by marksmithhfx
Klaus wrote: ↑Sat Jan 09, 2021 2:24 pm
how can your user "re-order" your dg?
No script(s) involved where you can "hook on"?
Klaus
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
Re: dg2 row re-ordering
Posted: Tue Jan 12, 2021 3:14 pm
by marksmithhfx
dunbarx wrote: ↑Sat Jan 09, 2021 6:58 pm
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
Hi 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.
Re: dg2 row re-ordering
Posted: Tue Jan 12, 2021 3:31 pm
by Klaus
marksmithhfx wrote: ↑Tue Jan 12, 2021 3:00 pm
Klaus wrote: ↑Sat Jan 09, 2021 2:24 pm
how can your user "re-order" your dg?
No script(s) involved where you can "hook on"?
Klaus
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)...
ah, I see.
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...
...
what you obviously already do.
Best
Klaus