Solved

Turbopower Orpheus - TOvcTable - When to modify data after user finishes a cell edit

Posted on 2013-11-11
8
639 Views
Last Modified: 2013-11-20
I am using an Orpheus TOvcTable component with good success on a form.  
However, once the user has successfully edited a cell value, I'd like to sort the underlying data and redisplay the data in its sorted form.  The whole set of data for display in the table is only some 20 records of some 4 fields and will be quickly sorted and redisplayed by having the whole table repaint itself.
I can't decide upon which OnXXX event to choose to implement my sorting routine.  There seems to be such interaction between the table and its attached cell editing components that I can't deduce the proper one and proper time to perform this post edit action.  I don't need to change focus to another control from the TOvcTable during the sort's manipulation of the underlying data.
Any insight please?
0
Comment
Question by:scox12
  • 4
  • 3
8 Comments
 
LVL 36

Expert Comment

by:Geert Gruwez
ID: 39640474
onPost should do it
onAfterEdit will not have posted the saved data to the db

closing and reopening the query should work in the onPost
0
 

Author Comment

by:scox12
ID: 39640658
Thanks to Geert_Gruwez for the suggestion.  However, an Orpheus TOvcTable is not a database table but rather a visual component that doesn't have an onPost event.  It does have an OnDoneEdit event that says that it is "called just after the data has been saved from the edited cell."  It cautions that it "is triggered in the middle of a focus change" and that the user "cannot cause another focus change to happen." (from page 1066 of the user manual)
This event was the one that I have come to think would be the one that I should use to trigger my sorting routine.  
Would my assumption be correct?
0
 
LVL 36

Expert Comment

by:Geert Gruwez
ID: 39640882
i wasn't talking about the TOvcTable, but the dataset component
usualy TQuery, TTable, TADOTable, etc
I see i didn't indicate that

The TOvcTable will probably be linked to a TDatasource and that will be linked to a TTable (or other TDataset descendant)

there is no point in catching this on the visual component

>> has been saved from the edited cell.
this means the internal visual component (TOvcTable) memory structure

On a side note, how old is TOvcTable ?
I remember using it over a decade ago, but my memory is a little shallow from back then
didn't know it was still around
0
 
LVL 25

Expert Comment

by:Sinisa Vuk
ID: 39640957
Maybe you can use "post" sorting with windows messaging (handle own message):
const WM_MY_ACTION = WM_USER + 100;
...
procedure MsgHandler(var msg : TMessage); message WM_MY_ACTION;
....
procedure TfrmKasa.MsgHandler(var msg: TMessage);
begin
  //do sort here or something else.....
end;

//in some Onxxxxx event:
PostMessage(Self.Handle, WM_MY_ACTION, 0, 0);

Open in new window

0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:scox12
ID: 39642217
Thanks for your continued interest Geert_Gruwez and to sinisav for weighing in.
@Geert_Gruwez: My underlying difficulty is in determining when the modified data has finished being saved and when it's safe to then modify that saved data by other routines.  TOvcTable does not have a linked TTable so I can't simply observe when that has finished being updated.  TOvcTable is designed with the idea of being able to have great flexibility in how it obtains the data that it displays, not just that from a table.  
I'm testing the use of the OnDoneEdit event to see if that event occurs at a point after data updates have completed.  Will report back on success or not.
The TOvcTable does, however, have a descendant class, TOvcDbTable, that is data-aware.   I will look at its source to try to determine when it posts changes to its dataset and use that timing to try to ferret out timing for TOvcTable itself.
@sinisav: Triggering the sort shouldn't be a difficulty, once I figure out when it's safe to do it.  The numerous choices of events triggered by edits of TOvcTable's data are what's giving me pause.  Selecting the last one without violating a focus change is what's scaring me.
Bye-the-bye, Orpheus is actively updated on Sourceforge by maintainers more skilled than I.  It's XE4 compatible and XE5 will soon be achieved.  Thanks, too, to them for ongoing tool maintenance!
0
 
LVL 36

Expert Comment

by:Geert Gruwez
ID: 39643809
if it's not a data-aware component then there should be a piece of code to fill up the component
in most components the distinction is given with bound and unbound examples
bound meaning linked to a datasource
unbound meaning, you need to fill the component by code

have you tried creating a separate project to find how the TOvcTable works ?
moving pieces of code from the old to the demo project should help find out how the original project works
0
 

Accepted Solution

by:
scox12 earned 0 total points
ID: 39652697
@Geert_Gruwez: Yes, the component requires binding code, the address of the data item, that points to the particular item at the row/column of the component.  This portion of the code is functional and working correctly.  To some degree the component is semi-data aware with that data item's address performing the transmission of what the user sees in the component into and out of the underlying persistent storage.
I'd hoped that someone would have experience in using the component and could answer my question without too much difficulty.   Perhaps the vintage of the component has worked against that.
I've some DUnit that indicates that the safe location to put post update modifications to the persistent storage's data is in the OnDoneEdit event handler, like so:
procedure TdlgConsumableSort.OvcTableConsumableSortOrderDoneEdit
  ( Sender : TObject; RowNum, ColNum : Integer );
var
  PostEditData : TGridColumnInfo;
begin
  inherited;
  PostEditData := FvFileSortMgrForConsumableVTable.GridColumnInfoArray
    [ RowNum ];
  if DataWasEdited( PostEditData ) then begin
    SortTableData( PostEditData, RowNum );
  end;
end;

Open in new window

Where the method SortTableData has access to the whole GridColumnInfoArray array.
This solves my difficulty and can be accepted as the solution.
Thank you all for your help and time.
0
 

Author Closing Comment

by:scox12
ID: 39662092
Experimentation with the component's various event handlers that are triggered when the user edits the values displayed to the user, allowed me to track down the event handler to use.  That is the OnDoneEdit event handler.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now