Page 1 of 1

dcbrowse - insert row (new record)

Posted: Wed Feb 23, 2022 8:27 am
by Maxz
if I have to add a record in a dbf using TBROWSE() and hybride mode of xbase, I simulated the insertion by going to the end of the browse and creating a space (simulating a fake new line using SCROLL() for example) by to allow the GETs to compile them.

if the data was confirmed, then I would append the record by recording the information and position myself on the entered record.

if I canceled the operation, I would position myself on the previously saved record and restore the screen using RESTSCREEN to return to the previous situation

in Gui mode how should I behave to get the same result?
how do you manage the insertion of a new record directly on the browse?

Re: dcbrowse - insert row (new record)

Posted: Wed Feb 23, 2022 8:37 am
by rdonnay
Look at the Cell editing sample in \exp20\samples\browse\celledit.prg

Re: dcbrowse - insert row (new record)

Posted: Wed Feb 23, 2022 8:52 am
by Maxz
but CellEdit example creates a new record (append) ?

I do not think there is the possibility to add a new record but only to edit the existing one

Re: dcbrowse - insert row (new record)

Posted: Wed Feb 23, 2022 9:14 am
by rdonnay
The append feature of cell-editing only works with arrays.
If you want to add a new record, then I suggest that you use the ::hitBottomBlock callback of the XbpBrowse() class to add the record.
DC_XbpBrowse is derived from XbpBrowse so it follows all rules of XbpBrowse class.

Look at the Alaska documentation for XbpBrowse

Re: dcbrowse - insert row (new record)

Posted: Sun Feb 27, 2022 4:32 am
by Maxz
I started to experiment with the technique of inserting a new record and position myself at the bottom of the browse:

//----------------
DBAPPEND()
oBrowse:goBottom()
oBrowse:forceStable()

AEval( oBrowse:aColumns, {|o| o:DataArea:setCell( oBrowse:RowPos, NIL ) } ) // clear data ROW
oBrowse:deHilite()
AEval( oBrowse:aColumns, {|o| o:Redraw() } ) // redraw columns

// editing of new record
//
//

// if CANCEL
DBDELETE()
oBrowse:goBottom()
oBrowse:forceStable()
oBrowse:hilite()
AEval( oBrowse:aColumns, {|o| o:Redraw() } ) // redraw columns


// if CONFIRM
oBrowse:hilite()
AEval( oBrowse:aColumns, {|o| o:Redraw() } ) // redraw columns


I don't like this way of working so much because I have to insert a physical record and delete it if the user abandons the insertion

first chance
I would like to make a fake refresh of the records up to simulate the insertion and possibly return to the previous situation

second chance
save the screen (GraSaveScreen()) and restore it but I'm afraid to mishandle the coordinates of the browse rows

Re: dcbrowse - insert row (new record)

Posted: Tue Mar 01, 2022 2:28 am
by Maxz
could I be of help using the quickbrowse (DCQUICKBROWSE) instead DCBROWSE?

I could think of positioning myself on the last record of the database and then have a vertical pan up - another feature of xbpquickbrowse, correct ?

I have to understand, however, how the pan function is carried out (\XPPW32\SOURCE\SYS\Source\UI\BROWSE\xbp_qbrw.prg is the correct source ?)

I played on some controls ... see attached example
test3.zip
(62.52 KiB) Downloaded 213 times
- first problem: I can't position myself correctly in the empty line
- second problem: I can't create a new GetList by overlapping the browse below

Re: dcbrowse - insert row (new record)

Posted: Wed Mar 02, 2022 4:35 am
by Tom
I will take a closer look at what you're trying to do, but just one first impression: If you want to have a control to be redrawn (without re-reading the data), just use the method "invalidateRect". oBrowse:InvalidateRect() will repaint the browse without re-reading the data (oBrowse:RefreshAll()), and without flickering.

I don't know exactly what you mean with "vertical pan up", but I suppose it's something like "Up" and "Down" (or GoBottom) you also have in DCBROWSE/XbpBrowse, no matter which datasource is connected.

Re: dcbrowse - insert row (new record)

Posted: Wed Mar 02, 2022 9:51 am
by Maxz
I solved the problem in this way, using DCBROWSE instead DCQUICKBROWSE (not recommended by Roger) :
test1.zip
(62.77 KiB) Downloaded 220 times

- go to the bottom of the db
- perform :forceStable()
- redisplay all content of browse shifting up by 1 all values
- clear current row
- perform my GETs using new DCREAD loop
- refresh all browse using :forceStable()
- redisplay row cursor of browse
- return to browse
Tom, Roger
do you give me your opinion on any mistakes I made?