PDA

View Full Version : Force refresh of cDbCJGrid



Dennis Kirkeby
18-Aug-2010, 05:03 AM
Since Beginning_of_data don’t work anymore, what do I use instead?

How do I force a refresh of a grid, when the grid is empty?

Problem:
My grid is empty (Read-only). I create a record in a popup window and save it.
Find_First don’t work, I'm guessing because, I dont have any records in the grid.

To make the grid read only I have set these properties:
Set pbAllowEdit to False
Set pbFocusSubItems to False
Set pbReadOnly to True
Set pbSelectionEnable to True

Dennis Kirkeby - Novax A/S

Garret Mott
18-Aug-2010, 06:53 AM
Hi Dennis -

Try this:



Get phoDataSource to hoDataSource
Send Reset of hoDataSource
Send MoveToFirstRow

Dennis Kirkeby
18-Aug-2010, 07:24 AM
Thank you :)

It works.

Garret Mott
18-Aug-2010, 08:14 AM
Great!

I added two procedures to my subclass of the grids:



Procedure BeginningOfData
Handle hoDataSource

Get phoDataSource to hoDataSource
Send Reset of hoDataSource
Send MoveToFirstRow
End_Procedure

Procedure EndOfData
Handle hoDataSource

Get phoDataSource to hoDataSource
Send Reset of hoDataSource
Send MovetoLastRow
End_Procedure
I purposely left the underscores out so they're just a bit different from the old grid's procedures

John Tuohy
18-Aug-2010, 10:11 AM
Garret,

I would advise:


Procedure BeginningOfData
Send MoveToFirstRow
End_Procedure

Procedure EndOfData
Send MoveToLastRow
End_Procedurewhich suggests that these extra messages are not needed.

With dynamic cDbCJGrids the datasource is reset, the first/last record is found and the surrounding records are loaded. With static cDbCJGrids and regular cCJGrids, it just moves to the first/last row. Your code would not work with cCJGrids (and I'll guess you've not added it there) or with static cDbCJGrids as you'd be clearing data that is supposed to be static.

-John

Garret Mott
18-Aug-2010, 11:51 AM
Not only suggests... It tells me that MoveToFirstRow & MoveToLastRow no longer need augmentation to refresh the data.

Is that the case? If so - I'll just use them instead of my Procs.

Thanks John -

John Tuohy
18-Aug-2010, 11:55 AM
In alpha there was a bug that required this - but not more.

-John

Garret Mott
18-Aug-2010, 11:57 AM
Excellent - thanks!

Michael Mullan
20-Dec-2010, 03:25 PM
This is all well and good, but WHEN do I send it?

When I find a new Customer record, I want the "Invoice History" cjDBGrid to have the most recent invoice selected, and at the top of the grid. I can't decide where the
Send MoveToFirstRow

actually goes.

Help?

Garret Mott
20-Dec-2010, 06:50 PM
This is all well and good, but WHEN do I send it?

When I find a new Customer record, I want the "Invoice History" cjDBGrid to have the most recent invoice selected, and at the top of the grid. I can't decide where the
Send MoveToFirstRow

actually goes.

Help?

I put it in Matt Davidian's AfterRecordFound_msg of the Customer_DD (actually - in the procedure that it calls & assuming Customer is the main DD). I use that because I have not had good luck with OnNewCurrentRecord.

danwalsh46
21-Dec-2010, 10:12 AM
The original question involved displaying a record in a ReadOnly cCJdbgrid created using a dialog. In the old dbList's it's my practice to instantiate the dialog using a function that returns a RowId. I then find that record sending FindByRowId to the DDO and then a "Send Refresh_Page of oMyDbList Fill_From_Center." If the new record falls somewhere in the middle, what the equivalent of Refresh_Page in the new lists?

Garret Mott
21-Dec-2010, 10:30 AM
Hi Dan -

Check out RefreshDataFromExternal & RefreshDataFromDD. Not sure which one will work best for you in this case - but I think one of these is what you want.

danwalsh46
22-Dec-2010, 11:17 AM
I'm working with test data and not a lot of it, but just sending the FindByRowId message to the DDO seems to be working fine.