Preload data for using Xbrouwe EditSource(.T.)

Preload data for using Xbrouwe EditSource(.T.)

Postby Marc Venken » Wed May 01, 2019 8:14 am

Can we preload data when using the editsource() function from Xbrowse, without building a own adit function ?

Code: Select all  Expand view  RUN

 oBrw:EditSource(.T., "klant_nr,Naam_1,Straat,Postcode,Gemeente" )
 


some edit values should contain data before the edit is shown.

I don't see a array of predefined values in the xbrowse source code, but I can be wrong.

Maybe I need to use the : oBrw:bEdit := { |oRec| Editfunction( oRec ) }
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1446
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Preload data for using Xbrouwe EditSource(.T.)

Postby nageswaragunupudi » Wed May 01, 2019 8:45 am

Can you please try this?
Code: Select all  Expand view  RUN
oBrw:bDataRow := <|oBrw,cFieldList,lNew|
    local oRec := TDataRow():New( oBrw:uDataSource, cFieldList, lNew )
   if oRec:RecNo == 0  // new record
      oRec:SetDefault( fieldname, yourvalue )
   endif
   return oRec
   >
 
Regards

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

Re: Preload data for using Xbrouwe EditSource(.T.)

Postby nageswaragunupudi » Wed May 01, 2019 4:56 pm

From FWH 1904 we can write
Code: Select all  Expand view  RUN
oBrw:EditSource(.T., "klant_nr,Naam_1,Straat,Postcode,Gemeente" , { nil, "somename", nil, nil, cGemeente })

The non empty values in the array in the 3rd paramter will be initially assigned to the fileds in that order.
Regards

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

Re: Preload data for using Xbrouwe EditSource(.T.)

Postby Marc Venken » Wed May 01, 2019 6:14 pm

nageswaragunupudi wrote:From FWH 1904 we can write
Code: Select all  Expand view  RUN
oBrw:EditSource(.T., "klant_nr,Naam_1,Straat,Postcode,Gemeente" , { nil, "somename", nil, nil, cGemeente })

The non empty values in the array in the 3rd paramter will be initially assigned to the fileds in that order.


Very Nice.. Waiting to update ))
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1446
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Preload data for using Xbrouwe EditSource(.T.)

Postby Marc Venken » Wed May 01, 2019 6:25 pm

nageswaragunupudi wrote:Can you please try this?
Code: Select all  Expand view  RUN
oBrw:bDataRow := <|oBrw,cFieldList,lNew|
    local oRec := TDataRow():New( oBrw:uDataSource, cFieldList, lNew )
   if oRec:RecNo == 0  // new record
      oRec:SetDefault( fieldname, yourvalue )
   endif
   return oRec
   >
 


It works for getting the data into the editdialog, but the data that are displayed in the edit dialog will not be saved ? Data that I change saves, but not the predifined data.

It also seems that the lenght of the data input is not as long as the fields are.

My Code

Code: Select all  Expand view  RUN

function klantbrowse(oDlg,oDbfklant)

   local oDlg1, obrw , nWild:=2 , oSay, oGet, cUpper
   public a_Veldnaam:={}
   dbselectarea("klant")
   klant->(dbsetorder("klantnaam"))
   klant->(dbgotop())

   DEFINE FONT oBold NAME 'CALIBRI' SIZE 0,-12 BOLD
   DEFINE FONT oFont NAME "CALIBRI" SIZE 0,-14
   DEFINE FONT oFontBig NAME "CALIBRI" SIZE 0,-24

   DEFINE DIALOG oDlg1 SIZE 1000,730 PIXEL TRUEPIXEL ;
   STYLE nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION, WS_SYSMENU,WS_MAXIMIZEBOX, WS_MINIMIZEBOX, WS_THICKFRAME );
   TITLE "Klantenlijst : ";
   GRADIENT { { 1, nRGB( 125, 155, 175 ), nRGB( 125, 155, 175 ) } }

   aVelden :=  { ;
   { "klant_nr" , "Code"    ,nil,  65 }, ;
   { "Naam_1"   , "Naam"    ,nil,  250 }, ;
   { "straat"   , "Straat"  ,nil, 250 }, ;
   { "gemeente" , "Gemeente",nil, 150 }, ;
   { "selectie" , "Sel"   ,nil,  40 }}

   @ 0,0 XBROWSE oBrw size -1,-50 PIXEL OF oDlg1 font oFont ;
      DATASOURCE "klant" ;
      COLUMNS aVelden ;
      AUTOSORT CELL LINES NOBORDER FOOTERS

   oBrw:SetChecks()
   oBrw:lHScroll := .F.
   oBrw:nHeadStrAligns  := AL_CENTER
   oBrw:naam:bLClickHeader := {|| oBrw:Seek( "" ), oBrw:cFilterFld := "Naam_1" }
   oBrw:straat:bLClickHeader := {|| oBrw:Seek( "" ), oBrw:cFilterFld := "Straat" }
   oBrw:bDataRow := <|oBrw,cFieldList,lNew|
       local oRec := TDataRow():New( oBrw:uDataSource, cFieldList, lNew )
       if oRec:RecNo == 0  // new record
          //  Working
          oRec:SetDefault( "klant_nr", "120" )
          oRec:SetDefault( "naam_1", "Naam Test" )
          oRec:SetDefault( "straat", oBrw:cSeek )

          // not working yet because I can't find the current Col Number
          //xbrowser(oBrw)
          //msginfo(oBrw:oCol:nColadvance)
          //msginfo(oBrw:oCol():nCreationorder)
          // Here I want based on the current colomn to put the Seek data in that field
          /*
          if oBrw:oCol() =  2
             oRec:SetDefault( "naam_1", oBrw:cSeek )
          elseif oBrw:oCol() =  3
             oRec:SetDefault( "straat", oBrw:cSeek )
          endif
          */

       endif
       return oRec
       >

   WITH OBJECT oBrw

      :lIncrFilter   := .t.
      :lSeekWild     := ( nWild == 2 ) // 1 left/right : 2 wild
      :lHScroll      := .f.

      :cFilterFld    := "straat"
      :bFooters         := { |oCol| If( Empty( oCol:cOrder ), "", oBrw:cSeek("") ) }

      :nStretchCol   := 2
      :bClrEdits        := { || { CLR_BLACK, CLR_YELLOW }}

      :bLDblClick := { || oBrw:EditSource(.F., "klant_nr,Naam_1,Straat,Postcode,Gemeente" ) }

      :nColDividerStyle := LINESTYLE_LIGHTGRAY
      :nRowDividerStyle := LINESTYLE_LIGHTGRAY
      :bClrRowFocus     := { || { CLR_BLACK, RGB(185,220,255) } }
      :nMarqueeStyle    := MARQSTYLE_HIGHLROWMS

      :bClrSelFocus = {|| { CLR_WHITE, RGB(0, 128, 128) } } // CUANDO TIENE EL FOCUS

      :oHeaderFonts     := oBold
      :bKeyDown   := { |k| If( k == VK_RETURN,( oDlg1:end() ),nil ) }

   END

   oBrw:CreateFromCode()

   @ 690,500 BTNBMP PROMPT "<- Blanco" ;
      SIZE 100,25 PIXEL OF oDlg1;
      ACTION ( addnewprospect(oDlg1,oBrw ) )

   ACTIVATE DIALOG odlg1 centered

   oFont:end()

return NIL

function addnewprospect(oDlg1,oBrw)
   DEFINE CLIPBOARD oClp
   cCode := oBrw:cSeek
   oClp:SetText( cCode )

   oBrw:EditSource(.T., "klant_nr,Naam_1,Straat,Postcode,Gemeente" )
return NIL

 


If you have any suggestions in altering the browse code, please do ... I like the learning process..
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1446
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Preload data for using Xbrouwe EditSource(.T.)

Postby nageswaragunupudi » Thu May 02, 2019 2:33 am

// Here I want based on the current colomn to put the Seek data in that field
/*
if oBrw:oCol() = 2
oRec:SetDefault( "naam_1", oBrw:cSeek )
elseif oBrw:oCol() = 3
oRec:SetDefault( "straat", oBrw:cSeek )


Code: Select all  Expand view  RUN

oRec:SetDefault( oBrw:SelectedCol():cExpr, oBrw:cSeek )
 


It also seems that the lenght of the data input is not as long as the fields are.

You need to pad the strings to the correct length while assigning.
Regards

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

Re: Preload data for using Xbrouwe EditSource(.T.)

Postby Marc Venken » Fri May 03, 2019 7:31 am

Still, the preloaded data is seens in the edit dialog, but will not be saved ?

It seems that only the inputfields that are changed are saved, not the fields that are filled with preloaded data.

Can this be a issue from FW ? I would like to use the standards of FW for this kind of small dialogs.
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1446
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Preload data for using Xbrouwe EditSource(.T.)

Postby nageswaragunupudi » Fri May 03, 2019 7:32 am

I will check again and get back to you.
Can you let me know which version are you using for testing? FWH1903?
Regards

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

Re: Preload data for using Xbrouwe EditSource(.T.)

Postby Marc Venken » Fri May 03, 2019 9:30 am

Version 18.12
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1446
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Preload data for using Xbrouwe EditSource(.T.)

Postby Marc Venken » Fri May 03, 2019 12:19 pm

Same problem in when i use 19.03
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1446
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Preload data for using Xbrouwe EditSource(.T.)

Postby nageswaragunupudi » Sat May 04, 2019 8:23 am

Please try
Code: Select all  Expand view  RUN
oRec:FieldPut( fldname, value )

instead of
Code: Select all  Expand view  RUN
oRec:SetDefault( fldname, value )
Regards

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

Re: Preload data for using Xbrouwe EditSource(.T.)

Postby nageswaragunupudi » Sat May 04, 2019 2:29 pm

We confirm the problem that the values used in SetDefault() are not being saved. We fixed it in the next version FWH1904.
Till then you may use FieldPut() as I explained above.
Regards

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 40 guests