To Mr. G. N. Rao

To Mr. G. N. Rao

Postby Armando » Mon Apr 29, 2013 3:31 pm

Mr. Rao:

I'm looking for a xBrowse example, whit cells edit, add new rows and using a record set, where can I found it?

I've searched this forum but the examples are for DBFs or Array

Regards and thanks so much
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3061
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: To Mr. G. N. Rao

Postby nageswaragunupudi » Mon Apr 29, 2013 4:52 pm

fwh\samples\testxbr3.prg shows browse of dbf, array and ado.
Please study and if you have any doubts or need any further support please let us know.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: To Mr. G. N. Rao

Postby Armando » Mon Apr 29, 2013 5:54 pm

Mr. Rao:

Thanks, I'll

Regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3061
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: To Mr. G. N. Rao

Postby Armando » Mon Apr 29, 2013 10:25 pm

Mr. Rao:

I have the next example

Code: Select all  Expand view

        REDEFINE XBROWSE oBrw ID 200 OF oDlg RECORDSET oRsCli ;
        COLUMNS "CLI_NOM","CLI_RFC","CLI_CLI","CLI_DDC" ;
        HEADERS "Razón Social","Reg.Fed.Con.","Número","Dias" ;
        COLSIZES 400 ;
        LINES FASTEDIT AUTOSORT FOOTERS CELL

            WITH OBJECT oBrw
                :l2007                      := (.F.)    // Sin esta línea no toma los colores de Head & Foot
                :lFooter                        := (.T.)
                :nHeaderHeight              := 30
                :nRowHeight                 := 22
                :bClrHeader                 := { || {CLR_WHITE,CLR_BLACK} }
                :nRecSelColor               := { || {nRGB(CLR_BLACK),nRGB(CLR_WHITE)} }
                :bClrFooter                 := { || {CLR_WHITE,CLR_BLACK} }

                :bClrStd                        := {|| IIF(oBrw:KeyNo() % 3 == 0,{ CLR_BLACK, RGB(217,217,255)},{CLR_BLACK,CLR_WHITE}) }
                :bClrSel                        := {|| { CLR_WHITE, CLR_BLACK} }
                :bClrSelFocus               := {|| { CLR_WHITE, CLR_HBLUE} }

                :nRecSelColor               := nRGB(217,217,255)
            END


            WITH OBJECT oBrw:aCols[01]
            :nEditType      := EDIT_GET
            :cEditPicture   := "@!K"
            END

            WITH OBJECT oBrw:aCols[02]
            :nEditType      := EDIT_GET
            :cEditPicture   := "@R !!!!-999999-!!!"
            END

            WITH OBJECT oBrw:aCols[03]
            :nEditType      := EDIT_GET
            :nDataStrAlign  := 1        // 1=Der,2=Cen,3=Izq
            :cEditPicture   := "99999"
            END

            WITH OBJECT oBrw:aCols[04]
            :nEditType      := EDIT_GET
            :nDataStrAlign  := 1        // 1=Der,2=Cen,3=Izq
            :cEditPicture   := "999"
            END
 


and it Works fine using a record set, now I need add a new record (row) how can I do that, any advice or clue?

Regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3061
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: To Mr. G. N. Rao

Postby nageswaragunupudi » Tue Apr 30, 2013 4:13 am

If you like to capture the new record values in a dialog, that is much easier and safer.
You can use oBrw:oRs:AddNew() to create a blank record, offer edit in a dialog and then either save ( calling oBrw:oRs:Update()/UpdateBatch() ) or cancel append ( calling oBrw:oRs:CancelUpdate()/CancelBatch() ) depending on validation of the entire row.

If you want to create a blank row in the xbrowse itself and offer inline edit, you need to consider the following implications.

As you are aware you can open a recordset with adLockOptimistic or adLockBatchOptimistic.
In the first case, once you call oRs:AddNew(), you can not navigate the recordset unless you either Update() or CancelUpdate() the new row. For xbrowse it is necessary that the recordset should be navigated even after oRs:AddNew() is called and not saved/cancelled.

Therefore you need to open the RecordSet with BatchOptimistic locking.

In such a case you can add new row like this:
oBrw:bPastEof := { || If( <already in append mode>, nil, ( oBrw:oRs:AddNew(), oBrw:Refresh() ) }

You need to have your own logic inside your program to decide if there is already one new row that is yet to be edited and saved.

You also need to deal with situations when the user does not edit anything in the new row but moves to another existing row. In such a case you need to cancel the new row.

All this logic you need to create inside your program and xbrowse does not help by itself.

If you still want to to go ahead, first let me know the FWH version you are using.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: To Mr. G. N. Rao

Postby Armando » Tue Apr 30, 2013 4:22 pm

Mr. Rao:

I'll try your first advice.

My tools:

FWH 0810, xHarbour build 1.2.1 Intl. (SimpLex) (Rev. 9445), BCC55, PellesC and xMate

Tanks & Regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3061
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 94 guests