dcbrowse - insert row (new record)

This forum is for eXpress++ general support.
Post Reply
Message
Author
Maxz
Posts: 49
Joined: Sun Jan 09, 2022 12:11 pm

dcbrowse - insert row (new record)

#1 Post 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?

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: dcbrowse - insert row (new record)

#2 Post by rdonnay »

Look at the Cell editing sample in \exp20\samples\browse\celledit.prg
The eXpress train is coming - and it has more cars.

Maxz
Posts: 49
Joined: Sun Jan 09, 2022 12:11 pm

Re: dcbrowse - insert row (new record)

#3 Post 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

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: dcbrowse - insert row (new record)

#4 Post 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
The eXpress train is coming - and it has more cars.

Maxz
Posts: 49
Joined: Sun Jan 09, 2022 12:11 pm

Re: dcbrowse - insert row (new record)

#5 Post 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

Maxz
Posts: 49
Joined: Sun Jan 09, 2022 12:11 pm

Re: dcbrowse - insert row (new record)

#6 Post 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 202 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

User avatar
Tom
Posts: 1171
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: dcbrowse - insert row (new record)

#7 Post 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.
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

Maxz
Posts: 49
Joined: Sun Jan 09, 2022 12:11 pm

Re: dcbrowse - insert row (new record)

#8 Post by Maxz »

I solved the problem in this way, using DCBROWSE instead DCQUICKBROWSE (not recommended by Roger) :
test1.zip
(62.77 KiB) Downloaded 203 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?

Post Reply