views:

608

answers:

4

I've got a DevExpress TcxGrid, with an event handler attached to its GridView's OnEditValueChanged event that's supposed to summarize some data in one of the columns. Problem is, this event gets fired during validation, before the updated value has been written to the underlying dataset. I'm not too familiar with the TcxGrid. Does anyone know if there's a way to fire an event handler after the dataset has been updated?

+4  A: 

What about using the DataSource.OnDataChange event?

skamradt
This was the only idea that worked.
Mason Wheeler
+1  A: 

Do you use the cxTableView or cxDBTableView in the cxGrid

if you use the cxDBTableView then you set your event in the datasource.onchange of the linked datasource in the property of the cxDBTableView. (cxDBTableView .datacontroller.datasource)

Ravaut123
A: 

I'd go with skamradt : look more carefully for an event which matches your expectations.

Otherwise, you can plug your event after making sure your data is initialized :

 procedure TMyGrid.MyProc_OnDataLoaded( Sender : TObject ); //I made up this event, I'm not sure it exists
 begin
   Self.OnEditValueChanged := MyProc_OnEditValueChanged;
 end;

I would strongly advise you to NOT use this as a regular developping habbit (making an event set another callback through code is a sure way to debugging hell), but if you really don't find any other way to do it...

LeGEC
+1  A: 

I'm not sure if this is exactly what you need, but I have found the ImmediatePost option of the grid to be very useful for situations where I need to update a summary - it's buried under its Data Controller property of the cxView. This makes the grid act like a spreadsheet - as soon as the user presses enter or tab in a cell, the record gets posted. Then I would have my summarising event fire from the AfterPost event of the dataset, perhaps?

(You probably already know this but the gridview itself has a lot of very useful summarising options built into it - look at the Summary properties of the columns, and make sure ShowFooter is set to true in the ViewOptions - so if your summary is a relatively simple total or average or similar, let the grid do it all and save yourself some work.)

RichardS
A simple summary won't work. I like the ImmediatePost idea, though. I'll check it out when I get in to work this morning and see if it does what I need.
Mason Wheeler
Nope. Turns out that doesn't make it post before the event handler fires.
Mason Wheeler