Page 1 of 1

Xbrowse aCols -> user function

Posted: Tue Feb 08, 2022 10:36 am
by Silvio.Falconi
Dear NAges,
when I open a Xbrowse I sent the configuration of columns sample :

Code: Select all | Expand


   aCols    := { ;
        { "DESCRAGE",  "Denominazione"        ,,   200, },;
        { "IND",       "Indirizzo"            ,,   200, },;
        { "CODCATP",   "Categoria Provvigioni",,   100, }}
 


but we often have to change the content of the field through user functions such as the field CODCATP of the sample

WITH OBJECT oBrwAge
WITH OBJECT oBrwAge:aCols[3]
:bEditValue :={ || GiveMeProvv(oAgenti:CODCATP) }
END

since I wanted to create a Table () function to display a window of the archives for selection
so as not to change it every time can it be created in order to pass the function through aCols?

example

aCols := { ;
{ "DESCRAGE", "Denominazione" ,, 200, },;
{ "IND", "Indirizzo" ,, 200, },;
{GiveMeProvv( "CODCATP"), "Categoria Provvigioni",, 200, }}

Re: Xbrowse aCols -> user function

Posted: Tue Feb 08, 2022 1:34 pm
by Marc Venken
Maybe this can be of help. (from project Mr. Rao gave the solution)

tn := oRs:FieldPos( "T" + alltrim( Str( month(date()))) + "_1" )

Code: Select all | Expand


   aVelden6 :=  { ;
    { "selection"  , "Sel"           ,nil,  25 }, ; // 1
    { "naam"       , "Naam"          ,nil, 90 , NIL}, ; // 3
    { "voornaam"   , "Voornaam"      ,nil, 90 , NIL}, ; // 4
    { "ploeg2018"  , "P2018"          ,"@!", 75, NIL}, ; // 5
    { "ploeg2017"  , "P2017"          ,"@!", 75, NIL}, ; // 5
    { "truitjesnum", "Num"          ,"999", 30 }, ;   // 16
    { "Actief"     , "Actief"        ,nil,  75 , NIL}, ; // 6
    { "Nonactief"  , "Beschikbaar"    ,"@D",  72 ,NIL},;   // 12
    { { |x| If( x == nil, oRs:FieldGet( tn ), oRs:FieldPut( tn , x ) ) },"T1","@!",  25 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+1 ), oRs:FieldPut( tn+1 , x ) ) },"T2","@!",  22 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+2 ), oRs:FieldPut( tn+2 , x ) ) },"T3","@!",  22 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+3 ), oRs:FieldPut( tn+3 , x ) ) },"T4","@!",  22 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+4 ), oRs:FieldPut( tn+4 , x ) ) },"T5","@!",  22 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+5 ), oRs:FieldPut( tn+5 , x ) ) },"T6","@!",  22 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+6 ), oRs:FieldPut( tn+6 , x ) ) },"T7","@!",  22 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+7 ), oRs:FieldPut( tn+7 , x ) ) },"T8","@!",  22 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+8 ), oRs:FieldPut( tn+8 , x ) ) },"T9","@!",  22 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+9 ), oRs:FieldPut( tn+9 , x ) ) },"T10","@!",  25 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+10 ), oRs:FieldPut( tn+10 , x ) ) },"MA1","@!",  30 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+11 ), oRs:FieldPut( tn+11 , x ) ) },"MA2","@!",  30 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+12 ), oRs:FieldPut( tn+12 , x ) ) },"MA3","@!",  30 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+13 ), oRs:FieldPut( tn+13 , x ) ) },"MA4","@!",  30 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+14 ), oRs:FieldPut( tn+14 , x ) ) },"MA5","@!",  30 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+15 ), oRs:FieldPut( tn+15 , x ) ) },"MB1","@!",  30 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+16 ), oRs:FieldPut( tn+16 , x ) ) },"MB2","@!",  30 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+17 ), oRs:FieldPut( tn+17 , x ) ) },"MB3","@!",  30 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+18 ), oRs:FieldPut( tn+18 , x ) ) },"MB4","@!",  30 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+19 ), oRs:FieldPut( tn+19 , x ) ) },"MB5","@!",  30 ,2}, ; // 9  // 2 is center
    { "opvolging"  , "Opv"           ,NIL, 30 ,NIL},;
    { "memo"       , "Memo"          ,"@!",  240 ,NIL}}

@ 0,0 XBROWSE oBrw[6] size -1,-1 PIXEL OF  oFld:aDialogs[ 6 ] font oFont ;
      DATASOURCE oRs ;
      COLUMNS aVelden6;
      AUTOSORT CELL LINES NOBORDER FOOTERS FASTEDIT

 

Re: Xbrowse aCols -> user function

Posted: Tue Feb 08, 2022 3:27 pm
by nageswaragunupudi

Code: Select all | Expand

aCols := { ;
{ "DESCRAGE", "Denominazione" ,, 200, },;
{ "IND", "Indirizzo" ,, 200, },;
{ "GiveMeProvv( CODCATP)", "Categoria Provvigioni",, 200, }}
 

This works if GiveMeProvv() is a "function" not a "static function"

If this is a static function, use

Code: Select all | Expand

aCols := { ;
{ "DESCRAGE", "Denominazione" ,, 200, },;
{ "IND", "Indirizzo" ,, 200, },;
{ {||GiveMeProvv( FIELD->CODCATP ) }, "Categoria Provvigioni",, 200, }}
 

Re: Xbrowse aCols -> user function

Posted: Tue Feb 08, 2022 3:34 pm
by nageswaragunupudi
Instead of

Code: Select all | Expand

   { { |x| If( x == nil, oRs:FieldGet( tn+1 ), oRs:FieldPut( tn+1 , x ) ) },"T2","@!",  22 ,2}, ;

Try

Code: Select all | Expand

   { oRs:FieldName( tn+1 ),"T2","@!",  22 ,2}, ;

Re: Xbrowse aCols -> user function

Posted: Tue Feb 08, 2022 5:49 pm
by Silvio.Falconi
THANKS RAO

Re: Xbrowse aCols -> user function

Posted: Wed Feb 16, 2022 6:04 pm
by Silvio.Falconi
nageswaragunupudi wrote:

Code: Select all | Expand

aCols := { ;
{ "DESCRAGE", "Denominazione" ,, 200, },;
{ "IND", "Indirizzo" ,, 200, },;
{ "GiveMeProvv( CODCATP)", "Categoria Provvigioni",, 200, }}
 

This works if GiveMeProvv() is a "function" not a "static function"

If this is a static function, use

Code: Select all | Expand

aCols := { ;
{ "DESCRAGE", "Denominazione" ,, 200, },;
{ "IND", "Indirizzo" ,, 200, },;
{ {||GiveMeProvv( FIELD->CODCATP ) }, "Categoria Provvigioni",, 200, }}
 




Nages,
on another archive I have problems, I cannot Show the data
the field RataIva is of 1 CR


the Dbf
Image




I tried with static function

local aCols := { ;
{ "CODPAG" , "Codice" ,, 40, },;
{ "DESC" , "Descrizione" ,, 120, },;
{ "TipoPagamento(SCADVIST)" , "Tipo Scadenza" ,, 120, },;
{ { ||RataIvaP(FIELD->RataIva) } , "Rata I.V.A." ,, 120, } }



Code: Select all | Expand


Static Function RataIvap(cTipo)
  local aTipo:={"Divisa su rate","Tutto su prima rata","Tutto su ultima rata","La prima è solo I.v.a." }
  local nNum:= val(ltrim(cTipo))
  local cString:= aTipo[nNum]
  return  cString
 


I have this result

Image





I tried also the no Static function

local aCols := { ;
{ "CODPAG" , "Codice" ,, 40, },;
{ "DESC" , "Descrizione" ,, 120, },;
{ "TipoPagamento(SCADVIST)" , "Tipo Scadenza" ,, 120, },;
{ "RataIvaP(RATAIVA)" , "Rata I.V.A." ,, 120, }}


Code: Select all | Expand

Function RataIvap(cTipo)
  local aTipo:={"Divisa su rate","Tutto su prima rata","Tutto su ultima rata","La prima è solo I.v.a." }
  local nNum:= val(ltrim(cTipo))
  local cString:= aTipo[nNum]
  return  cString


and I have this

Image


How I can resolve ?

Re: Xbrowse aCols -> user function

Posted: Wed Feb 16, 2022 9:48 pm
by Jimmy
hi Silvio,
Silvio.Falconi wrote:

Code: Select all | Expand


aCols    := { ;
        { "DESCRAGE",  "Denominazione"        ,,   200, },;
        { "IND",       "Indirizzo"            ,,   200, },;
        {GiveMeProvv( "CODCATP"),   "Categoria Provvigioni",,   200, }}

just a Shoot into Darkness

Code: Select all | Expand

       { &GiveMeProvv( "CODCATP"),   "Categoria Provvigioni",,   200, }}

Re: Xbrowse aCols -> user function

Posted: Wed Feb 16, 2022 9:56 pm
by Silvio.Falconi
do you see the nages's message?

Re: Xbrowse aCols -> user function

Posted: Thu Feb 17, 2022 11:09 am
by nageswaragunupudi

Code: Select all | Expand

function xbrtest05()

   local oDlg, oBrw, aCols

   aCols := ;
      {  { "FIRST",  "Name" } ;
      ,  { "RataIvaP(CITY)" , "Rata I.V.A.",,120  } ;
      }

   USE CUSTOMER NEW ALIAS "CUST" SHARED VIA "DBFCDX"

   DEFINE DIALOG oDlg SIZE 500,400 PIXEL TRUEPIXEL
   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE "CUST" ;
      COLUMNS aCols ;
      CELL LINES NOBORDER

   oBrw:CreateFromCode()

   ACTIVATE DIALOG oDlg CENTERED

return nil

Function RataIvap(cTipo)
  local aTipo:={"Divisa su rate","Tutto su prima rata","Tutto su ultima rata","La prima è solo I.v.a." }
//  local nNum:= val(ltrim(cTipo))
  local nNum := ( ASC( cTipo ) % 4 ) + 1
  local cString:= aTipo[nNum]
  return  cString
 


Image

Re: Xbrowse aCols -> user function

Posted: Thu Feb 17, 2022 12:06 pm
by Silvio.Falconi
nageswaragunupudi wrote:

Code: Select all | Expand

function xbrtest05()

   local oDlg, oBrw, aCols

   aCols := ;
      {  { "FIRST",  "Name" } ;
      ,  { "RataIvaP(CITY)" , "Rata I.V.A.",,120  } ;
      }

   USE CUSTOMER NEW ALIAS "CUST" SHARED VIA "DBFCDX"

   DEFINE DIALOG oDlg SIZE 500,400 PIXEL TRUEPIXEL
   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE "CUST" ;
      COLUMNS aCols ;
      CELL LINES NOBORDER

   oBrw:CreateFromCode()

   ACTIVATE DIALOG oDlg CENTERED

return nil

Function RataIvap(cTipo)
  local aTipo:={"Divisa su rate","Tutto su prima rata","Tutto su ultima rata","La prima è solo I.v.a." }
//  local nNum:= val(ltrim(cTipo))
  local nNum := ( ASC( cTipo ) % 4 ) + 1
  local cString:= aTipo[nNum]
  return  cString
 


Image



Nages,
Strange but I not understood why of a comma , { "RataIvaP(CITY)" , "Rata I.V.A.",,120 } ;

aCols := ;
{ { "FIRST", "Name" } ;
, { "RataIvaP(CITY)" , "Rata I.V.A.",,120 } ;
}

Re: Xbrowse aCols -> user function

Posted: Thu Feb 17, 2022 1:04 pm
by Silvio.Falconi
I found the error
When the field is empty give me zero