Browsing dataobjects (solved)

This forum is for eXpress++ general support.
Post Reply
Message
Author
Wolfgang Ciriack
Posts: 479
Joined: Wed Jan 27, 2010 10:25 pm
Location: Berlin Germany

Browsing dataobjects (solved)

#1 Post by Wolfgang Ciriack »

Hello Roger,
i have two questions about browsing dataobjects:
This is my Browse with an database:

Code: Select all

@12.5, 55.0 DCBROWSE oBrowse ;
		DATA cLstAl ;
		SIZE 55, 8 ;
		CURSORMODE XBPBRW_CURSOR_ROW ;
		NOHSCROLL ;
		FIT ;
		PRESENTATION aPres1 ;
		ITEMSELECTED {|| EditLstPos(oLstRec, oAufVar, oAufRec, .T.), oBrowseLeist:RefreshAll()} 

	DCBROWSECOL DATA {{|| hlst->LArtName1}, {|| hlst->LArtName2}} HEADER {"Artikel"} WIDTH 22	PARENT oBrowse
	DCBROWSECOL DATA {{|| hlst->LMenge},    {|| hlst->LEinheit}}  HEADER {"Menge"}   WIDTH  6	PARENT oBrowse
	DCBROWSECOL DATA {{|| hlst->LEPreis},   {|| ""}} 		  HEADER {"Preis"}   WIDTH  6	PARENT oBrowse
Now i want to change the datasource to an array of dataobjects:

Code: Select all

	DCBROWSECOL OBJECTVAR {|o| alltrim(o:LArtName1) + " " + alltrim(o:LArtName2)}	ELEMENT 1 HEADER "Artikel" WIDTH 22	PARENT oBrowse
	DCBROWSECOL OBJECTVAR {|o| str(o:LMenge) + " " + o:lEinheit}  	            ELEMENT 1 HEADER "Menge"   WIDTH  6	PARENT oBrowse
	DCBROWSECOL OBJECTVAR LEPreis   	                                          ELEMENT 1 HEADER "Preis"   WIDTH  6	PARENT oBrowse
This works, but how can i show the 2 lines of the "Artikel" ?

Second:
How can i use the EDITOR with dataobjects ?

Code: Select all

   @ 1, 1 DCBROWSE oBrowse ;
         DATA aData ;
         POINTER nP ;
         SIZE 80, 10 ;
         PRESENTATION DC_BrowPres() ;
         FIT ;
         NOHSCROLL ;
         TABSTOP ;
         FIT ;
         EDIT xbeBRW_ItemSelected MODE DCGUI_BROWSE_EDITACROSSDOWN EXIT {|| SetAppFocus(oBrowse)}

   DCBROWSECOL OBJECTVAR {|o| o:KArtName1} ELEMENT 1 HEADER "Bezeichnung" WIDTH 25 EDITOR "IDNA" PARENT oBrowseKK

   @ NIL, NIL DCGET xNIL GETID "IDNA" POPUP {|a, o, r| kkhelp(GetList, aData[nP, 1], a, o, "IDNA", NIL)} POPKEY xbeK_F1
if i enter some characters in the DCGET, they are not shown after i confirm field with enter (not saved in o:KArtName).
Same with the return value of the popup codeblock.

Are these two possible with browsing dataobjects ?
Last edited by Wolfgang Ciriack on Tue Apr 26, 2022 9:41 pm, edited 1 time in total.
_______________________
Best Regards
Wolfgang

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

Re: Browsing dataobjects

#2 Post by rdonnay »

Wolfgang -

This is the first time anyone has asked for this capability.
I am pleased to see that you are using Record Objects in your application.
The combination of Record Objects, Data Objects and Json strings really has improved productivity and debugging capabilities in Xbase++.

I will look into it this week and see how I can support you with cell editing of record objects.
Multi-row capability should already be possible using the owner-drawing feature of DCBROWSE.
The eXpress train is coming - and it has more cars.

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

Re: Browsing dataobjects

#3 Post by rdonnay »

I guess that I forgot that Cell Editing already works with an array of Record Objects.

Code: Select all

#INCLUDE "dcdialog.CH"
#INCLUDE "appevent.CH"

FUNCTION Main()

LOCAL GetList[0], oBrowse, oParts, aParts[0], aStru, i

DbeLoad("FOXDBE")
DbeLoad("CDXDBE")
DbeBuild("FOXCDX","FOXDBE","CDXDBE")

USE parts VIA 'FOXCDX'

aStru := PARTS->(dbStruct())

DO WHILE !PARTS->(Eof())
  oParts := PARTS->(DC_DbRecord():new())
  PARTS->(DC_DbScatter(oParts))
  AAdd(aParts,oParts)
  PARTS->(dbSkip())
ENDDO

@ 0,0 DCBROWSE oBrowse DATA aParts SIZE 100,20 FIT ;
      FONT '10.Lucida Console' ;
      EDIT xbeBRW_ItemSelected ;
      SUBCLASS 'DC_XbpBrowseFiltered()'

FOR i := 1 TO Len(aStru)

  DCBROWSECOL OBJECTVAR (aStru[i,1]) HEADER aStru[i,1] WIDTH aStru[i,3] PARENT oBrowse ;
    SORT _SortBlock(aStru[i,1],aParts) LEFTBUTTON _DEFAULT i==1 ;
    SUBCLASS 'DC_XbpColumnFiltered()' ;
    EVAL {|o|o:isColumnConfigEnabled := .t.}

NEXT

DCREAD GUI FIT TITLE 'Browsing Objects'


RETURN nil

* -----------

PROC appsys ; return

* -----------

STATIC FUNCTION _SortBlock( cFieldName, aObjects )

RETURN {||ASort(aObjects,,,{|a,b|a:&cFieldName<b:&cFieldName})}


The eXpress train is coming - and it has more cars.

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

Re: Browsing dataobjects

#4 Post by rdonnay »

Here is how to use the DCBROWSE Multirow capability with an array of DataObjects.

Code: Select all

#INCLUDE "dcdialog.CH"
#INCLUDE "appevent.CH"

FUNCTION Main()

LOCAL GetList[0], GetOptions, oBrowse, aDir, aPres, aColPres, ;
      aColPresLeft, aColPresRight, aObjects[0], i, oDir

aDir := Directory()

aPres := ;
  { { XBP_PP_COL_HA_FGCLR, GRA_CLR_WHITE },            /* Header FG Color  */  ;
    { XBP_PP_COL_HA_BGCLR, GRA_CLR_DARKGRAY },         /* Header BG Color  */  ;
    { XBP_PP_COL_DA_ROWSEPARATOR, XBPCOL_SEP_DOTTED }, /* Row Sep          */  ;
    { XBP_PP_COL_DA_COLSEPARATOR, XBPCOL_SEP_DOTTED }, /* Col Sep          */  ;
    { XBP_PP_COL_DA_FGCLR, GRA_CLR_BLACK },            /* Row FG Color     */  ;
    { XBP_PP_COL_DA_BGCLR, GRA_CLR_WHITE },            /* Row BG Color     */  ;
    { XBP_PP_COL_DA_ROWHEIGHT, 50 },                   /* Row Height       */  ;
    { XBP_PP_COL_HA_HEIGHT, 22 },                      /* Header Height    */  ;
    { XBP_PP_HILITE_FGCLR, GRA_CLR_BLACK },            /* Hilite FG color  */  ;
    { XBP_PP_HILITE_BGCLR, GRA_CLR_PALEGRAY },         /* Hilite BG color  */  ;
    { XBP_PP_COL_FA_FGCLR, GRA_CLR_WHITE },            /* Footer FG Color  */  ;
    { XBP_PP_COL_FA_BGCLR, GRA_CLR_DARKGRAY },         /* Footer BG Color  */  ;
    { XBP_PP_COL_DA_CELLALIGNMENT, XBPALIGN_TOP },     /* Alignment of text*/  ;
    { XBP_PP_COL_FA_HEIGHT, 10 }                       /* Footer Height    */  ;
  }

FOR i := 1 TO Len(aDir)
  oDir := DataObject():new()
  oDir:fileName := aDir[i,1]
  oDir:Size := aDir[i,2]
  oDir:Date := aDir[i,3]
  oDir:Time := aDir[i,4]
  AAdd(aObjects,oDir)
NEXT

@ 2,2 DCBROWSE oBrowse DATA aObjects SIZE 40,22 FIT ;
   PRESENTATION aPres ;
   HEADLINES 3 ;
   CURSORMODE XBPBRW_CURSOR_ROW ;
   FONT '10.Arial'

DCBROWSECOL DATA {||DC_GetColArray(1,oBrowse)} ;
            HEADER 'File Name;;' WIDTH 10 PARENT oBrowse ;
            FONT '12.Arial Bold'

DCBROWSECOL DATA { {||'Size: ' + Alltrim(Str(aObjects[oBrowse:arrayElement]:size))}, ;
                   {||'Date: ' + DtoC(aObjects[oBrowse:arrayElement]:date)}, ;
                   {||'Time: ' + aObjects[oBrowse:arrayElement]:time} } ;
            HEADER 'Stats' WIDTH 18 PARENT oBrowse ;
            FONT '10.Lucida Console'

aColPresRight := { { XBP_PP_COL_DA_CELLALIGNMENT, XBPALIGN_TOP+XBPALIGN_RIGHT }, ;
                 { XBP_PP_COL_HA_ALIGNMENT, XBPALIGN_RIGHT } }

DCBROWSECOL DATA { {||DC_TokenArray(DC_XtoC(aObjects[oBrowse:arrayElement]:date,'/')) } } ;
            HEADER 'Month;Day;Year' WIDTH 4 PARENT oBrowse ;
            PRESENTATION aColPresRight

aColPresLeft := { { XBP_PP_COL_DA_CELLALIGNMENT, XBPALIGN_TOP+XBPALIGN_LEFT }, ;
                  { XBP_PP_COL_HA_ALIGNMENT, XBPALIGN_LEFT } }

DCBROWSECOL DATA { {||Alltrim(Str(Month(aObjects[oBrowse:arrayElement]:date)))}, ;
                   {||Alltrim(Str(Day(aObjects[oBrowse:arrayElement]:date)))}, ;
                   {||Alltrim(Str(Year(aObjects[oBrowse:arrayElement]:date)))}} ;
            HEADER 'Month;Day;Year' WIDTH 4 PARENT oBrowse ;
          PRESENTATION aColPresLeft

DCREAD GUI ;
   FIT ;
   TITLE 'Multi-Row Browsing (Data Objects)' ;
   OPTIONS GetOptions

RETURN nil

PROC appsys
RETURN
The eXpress train is coming - and it has more cars.

Wolfgang Ciriack
Posts: 479
Joined: Wed Jan 27, 2010 10:25 pm
Location: Berlin Germany

Re: Browsing dataobjects

#5 Post by Wolfgang Ciriack »

Thank you Roger,
the multiline is working, the oBrowse:arrayElement was that, what i missed.
But the edit does not work. I try to send you an test program next days.
_______________________
Best Regards
Wolfgang

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

Re: Browsing dataobjects

#6 Post by rdonnay »

Cell editing is not supported in Multi-line browsing.
The eXpress train is coming - and it has more cars.

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

Re: Browsing dataobjects

#7 Post by Tom »

Cell-editing is a confusing mechanism. I do use this only in a very few cases. Having a separate editscreen ist much better.

Wolfgang, how should cell-editing work if the cell contains information concatenated from different sources?
Best regards,
Tom

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

Wolfgang Ciriack
Posts: 479
Joined: Wed Jan 27, 2010 10:25 pm
Location: Berlin Germany

Re: Browsing dataobjects

#8 Post by Wolfgang Ciriack »

Hello Roger, Tom,
these were two different items, multiline browse (solved) and cell editing. I only use cell editing in this context:
Old with database as source:

Code: Select all

  @ 1, 1 DCBROWSE oBrowse ;
         DATA cAlias ;
         EDIT xbeBRW_ItemSelected MODE DCGUI_BROWSE_EDITACROSSDOWN EXIT {|| SetAppFocus(oBrowseKK)}

   DCBROWSECOL FIELD hkk->KPos           HEADER "Nr."  WIDTH 3  PROTECT {|| .T.}  COLOR GRA_CLR_DARKBLUE, GRA_CLR_BACKGROUND  PARENT oBrowse
   DCBROWSECOL FIELD hkk->KArtName1 HEADER "Bezeichnung"  WIDTH 25 EDITOR "IDNA"  PARENT oBrowse
   DCBROWSECOL FIELD hkk->KMenge      HEADER "Menge"  WIDTH 6  EDITOR "IDME" PROTECT {|| empty(hkk->KArtName1)} PARENT oBrowse
...
   @ NIL, NIL DCGET xNIL GETID "IDNA" POPUP {|a, o, r| kkhelp(GetList, a, o, "IDNA", NIL)}  POPKEY xbeK_F1
   @ NIL, NIL DCGET xNIL GETID "IDME" VALID {|| makegsumme(....), .T.}
Now i try this with array of dataobjects, to get rid of temporary databases:

Code: Select all

  @ 1, 1 DCBROWSE oBrowse ;
         DATA aData ;
         POINTER nP ; ....
         EDIT xbeBRW_ItemSelected MODE DCGUI_BROWSE_EDITACROSSDOWN EXIT {|| SetAppFocus(oBrowseKK)}

   DCBROWSECOL OBJECTVAR {|o| o:KPos}   ELEMENT 1 HEADER "Nr."  WIDTH  3  PROTECT {|| .T.}  COLOR GRA_CLR_DARKBLUE, GRA_CLR_BACKGROUND PARENT oBrowse
   DCBROWSECOL OBJECTVAR {|o| o:KArtName1}   ELEMENT 1 HEADER "Bezeichnung" WIDTH 25 EDITOR "IDNA"                                                             PARENT oBrowse
...
   @ NIL, NIL DCGET xNil GETID "IDNA" POPUP {|a, o, r| kkhelp(GetList, @aData[nP, 1], a, o, "IDNA", NIL)} POPKEY xbeK_F1
   @ NIL, NIL DCGET xNIL GETID "IDME" VALID {|| makegsumme(....), .T.}
but this does not work anymore. I can enter some letters, but after ENTER the GET var is empty. Same with input from popup button function kkhelp, which returns a string.
_______________________
Best Regards
Wolfgang

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

Re: Browsing dataobjects

#9 Post by rdonnay »

I will need a sample program.
The eXpress train is coming - and it has more cars.

Wolfgang Ciriack
Posts: 479
Joined: Wed Jan 27, 2010 10:25 pm
Location: Berlin Germany

Re: Browsing dataobjects

#10 Post by Wolfgang Ciriack »

Hello Roger,
problem solved. My fault was, that i used DCBROWSECOL OBJECTVAR {|o| o:KPos}...
When looking in your sample browse\objects.prg i saw, that i can use simply DCBROWSECOL OBJECTVAR KPos ...
When using this, the editing works the same as i used with database cell editing.
Thank you for your help (and the samples) :D
_______________________
Best Regards
Wolfgang

Post Reply