XBROWSE Column Question

XBROWSE Column Question

Postby Jimmy » Wed May 03, 2023 10:03 pm

hi,

how can i "optimize" Column wide (STRETCHCOL_WIDEST)
how can i SET Cursor into 5th Column (also when outside Screen)
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: XBROWSE Column Question

Postby nageswaragunupudi » Thu May 04, 2023 10:08 am

how can i "optimize" Column wide (STRETCHCOL_WIDEST)

:nStretchCol := STRETCHCOL_LAST
Stretches the last column to fit the GridWidth
:nStretchCol := STRETCHCOL_WIDEST
Further stretches the widest character column to fit the GridWidth.
:nStretchCol := nCol
Similarly, stretches the column whose nCreationOrder is the same as nCol.

how can i SET Cursor into 5th Column (also when outside Screen)


Code: Select all  Expand view

oBrw:nSelCol := 5
oBrw:RefreshCurrent()
[/col]
or use :GoToCol( oCol )
oCol can be creationorder / header / column object
[code]
oBrw:GoToCol( 5 )
 

But we can go to only a column which is already visible on the screen. (not hidden or outside the grid width)
Regards

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

Re: XBROWSE Column Question

Postby Jimmy » Thu May 04, 2023 11:02 am

hi,
nageswaragunupudi wrote:But we can go to only a column which is already visible on the screen. (not hidden or outside the grid width)

thx for Answer

is there a Way to "scroll" horizontal by CODE :?:
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: XBROWSE Column Question

Postby nageswaragunupudi » Thu May 04, 2023 2:02 pm

oBrw:GoRight() // one column to the right
oBrw:GoRightMost() // go to last column
Regards

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

Re: XBROWSE Column Question

Postby Jimmy » Fri May 05, 2023 4:05 am

hi,
nageswaragunupudi wrote:oBrw:GoRight() // one column to the right
oBrw:GoRightMost() // go to last column

ok, thx for Answer
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: XBROWSE Column Question

Postby Jimmy » Fri May 05, 2023 7:08 am

hi,

after Answer of Method
Code: Select all  Expand view
   oBrw:GoRight() // one column to the right
   oBrw:GoRightMost() // go to last column

i have search for "more"

there is a
Code: Select all  Expand view
METHOD GoToCol( oCol ) CLASS TXBrowse

but no Sample how to use it ...

it seem this CODE work
Code: Select all  Expand view
  oBro:GoToCol(oBro:aCols[nPosi])


---

when switch ORDSETFOCUS() or SET INDEX TO i try to find Column in XBROWSE
when have NO "own" Header it will display Name of FIELD in Header

in this case this CODE will work where i use INDEXKEY() or OrdKey() to look which FIELD is used

Code: Select all  Expand view
STATIC FUNCTION FindColumnHeader( oBro )
LOCAL aHeaders := {}
LOCAL nPosi    := 0
LOCAL n, cSeek, aToken

   aToken := AtInside( "+", INDEXKEY() )  // -> hb_ATokens()

   // get rid of Function like UPPER() in IndexKey()
   cSeek := StripFunc( aToken[ 1 ] )

   FOR n := 1 TO LEN( oBro:aCols )
      AADD( aHeaders, oBro:aCols[ n ] :cHeader )
   NEXT
   // seek in Header if FIELD match
   nPosi := ASCAN( aHeaders, { | x | x = cSeek } )
   IF nPosi > 0
      // jump to Column
      oBro:GoToCol(oBro:aCols[nPosi])
   ENDIF

RETURN nPosi


Code: Select all  Expand view
STATIC FUNCTION StripFunc( cSeek )
LOCAL cRet := UPPER( cSeek )
LOCAL aToken

   cRet := STRTRAN( cRet, "UPPER(", "" )
   cRet := STRTRAN( cRet, "DTOS(", "" )
   cRet := STRTRAN( cRet, "STRZERO(", "" )
   cRet := STRTRAN( cRet, "STR(", "" )

   cRet := STRTRAN( cRet, ")", "" )

   IF "->" $ cRet
     aToken := AtInside( "->", cRet )
     cRet := aToken[LEN(aToken)]
   ENDIF

   IF "," $ cRet
     aToken := AtInside( ",", cRet )
     cRet := aToken[1]
   ENDIF

RETURN cRet


p.s. what is better to use INDEXKEY() or OrdKey() :?:
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: XBROWSE Column Question

Postby nageswaragunupudi » Sat May 06, 2023 2:03 am

in this case this CODE will work where i use INDEXKEY() or OrdKey() to look which FIELD is used


Code: Select all  Expand view
SET ORDER TO TAG "CITY"
nCol := AScan( oBrw:aCols, { |oCol| oCol:cSortOrder == OrdSetFocus() } )
? nCol
oCol := oBrw:aCols[ nCol ]
? oCol:nCreationOrder, oCol:cHeader, c:cExpr
// or even better
XBROWSER oCol 


Even if cHeader is different from the field name, oCol:cExpr contains the field name.

Now there is a short-cut.
Instead of writing this long code:
Code: Select all  Expand view
nCol := AScan( oBrw:aCols, { |oCol| oCol:cSortOrder == OrdSetFocus() } )
oCol := oBrw:aCols[ nCol ]
 

We can simply write
Code: Select all  Expand view
oCol := oBrw:oCol( "cSortOrder", OrdSetFocus() )
XBROWSER oCol
Regards

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

Re: XBROWSE Column Question

Postby nageswaragunupudi » Sat May 06, 2023 2:05 am

p.s. what is better to use INDEXKEY() or OrdKey() :?:

OrdKey()
Regards

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

Re: XBROWSE Column Question

Postby nageswaragunupudi » Sat May 06, 2023 2:09 am

STATIC FUNCTION StripFunc( cSeek )


XBrowse automatically uses similar logic to indentify which INDEX/ORDER to be used for which column and stores the INDEXNAME in the data oCol:cSortOrder, while initially building the browse.
XBrowse uses this information to do AutoSort
Regards

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

Re: XBROWSE Column Question

Postby Jimmy » Mon May 08, 2023 12:47 pm

hi,
nageswaragunupudi wrote:XBrowse automatically uses similar logic to indentify which INDEX/ORDER to be used for which column and stores the INDEXNAME in the data oCol:cSortOrder, while initially building the browse.
XBrowse uses this information to do AutoSort

what about Function in Indexkey() like STRZERO() :?:

it does work when have FIELD only but fail when have Function(FIELD), or :?:
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: XBROWSE Column Question

Postby nageswaragunupudi » Mon May 08, 2023 1:51 pm

what about Function in Indexkey() like STRZERO() :?:

Works
but fail when have Function(FIELD)

Does not fail. It works.
Regards

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

Re: XBROWSE Column Question

Postby Jimmy » Mon May 08, 2023 3:29 pm

hi,

FUNCTION FindColumnHeader() is NOT for "increment" Seek, it is to place Cursor on Header which meet IndexKey()

i can´t find e.g. STRZERO, in RddIncrSeek(), of XBROWSE ... but it seems to work ,,, how can it work ... hm
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: XBROWSE Column Question

Postby nageswaragunupudi » Tue May 09, 2023 9:44 am

Do you want to find the column object that is currently sorted on the ordsetfocus() ?

oBrw:oSortCol --> Currently sorted column obect. i.e., the column sorted on the ordsetfocus()
We can now get anything
oBrw:oSortCol:cHeader
oBrw:oSortCol:cExpr // field name

With XBrowse, most of the times, we do not have to write any special code.
Regards

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

Re: XBROWSE Column Question

Postby Jimmy » Tue May 09, 2023 8:35 pm

hi,

thx for Answer
nageswaragunupudi wrote:Do you want to find the column object that is currently sorted on the ordsetfocus() ?.

YES

nageswaragunupudi wrote:
Code: Select all  Expand view
oBrw:oSortCol --> Currently sorted column obect. i.e., the column sorted on the ordsetfocus()
We can now get anything
oBrw:oSortCol:cHeader
oBrw:oSortCol:cExpr  // field name

With XBrowse, most of the times, we do not have to write any special code.

it work when have "only" FIELD Name but seems not when have Function "in" INDEXKEY() / Ordkey()
so i "strip" all of String to get FIELD Name "only"

---

more Question :

how is the Syntax to use "Header - click" to SET Order / TAG :?:

in METHOD SetOrder( lSort ) i found OrdDescend()
how does OrdDescend() work :?:

when usig OrdWildSeek() in XBROWSE how to "continue" :?:
i did not found a 2nd OrdWildSeek() or a loop
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: XBROWSE Column Question

Postby nageswaragunupudi » Wed May 10, 2023 12:12 am

it work when have "only" FIELD Name but seems not when have Function "in" INDEXKEY() / Ordkey()
so i "strip" all of String to get FIELD Name "only"


I suggest this function, which can handle index key of any complexity.
If more than one field is used in the key expression, it returns the field name which occurs first in the key.
Code: Select all  Expand view
function FieldInKey( cKey )

   local aStruct := DBSTRUCT()
   local n  := 1
   local cToken, cSep, nAt

   cKey  := Upper( cKey )
   cKey  := StrTran( StrTran( cKey, "->", '!' ), '=', '!' )
   cKey  := CharRem( " ", cKey )

   do while !Empty( cToken := TOKEN( cKey, nil, n, nil, nil, @cSep ) )
      if !( cSep $ "!(" )
         if ( nAt := AScan( aStruct, { |a| a[ 1 ] = cToken } ) ) > 0
            return aStruct[ nAt, 1 ]
         endif
      endif
      n++
   enddo

return ""
 

Please test with any complex expression and see if it fails.
Regards

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

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 87 guests