checkbox on xBrowse with surplus info

checkbox on xBrowse with surplus info

Postby ellano » Tue Oct 09, 2018 10:07 am

When creating a checkbox column for an array I get the following case:

https://imgur.com/a/rawGRIt

The code is created this way:


Code: Select all  Expand view  RUN
 REDEFINE XBROWSE oBrwO ID 100 OF oDlg ARRAY aOrigen ;
    COLUMNS .F., 2,3,4,5,6,7, 8 ;
    COLSIZES  70, 20, 30, 20, 20, 8, 20, 10 ;
    HEADERS " ", "Number", "cSex", "Name", "Color", "Situation", "Location", "Date" ;
    CELL LINES NOBORDER

...

    oCol:= oBrwO:InsCol( 1 )

    WITH OBJECT oCol  //oBrwO:InsCol( 1 )
      :bEditValue    := { || AScan( oBrwO:aSelected, oBrwO:BookMark ) > 0 }     // checkbox for cell 1
      :SetCheck()
      :nHeadBmpNo    := { || If( Len( oBrwO:aSelected ) == oBrwO:nLen, 1, 2 ) } // image for cell 1
    END

    WITH OBJECT oBrwO
          :nMarqueeStyle    := MARQSTYLE_HIGHLROW
          :lMultiSelect     := .f.
          :bClrSelFocus     := { || { CLR_BLACK, CLR_HGRAY } }
          :nStretchCol      := 3
          :aCols[ 1 ]:bClrSelFocus := { ||{  CLR_BLACK, CLR_WHITE } }
          :bLClicked        := { |r,c,f,oBrwO| If( oBrwO:MouseColPos( c ) == 1 , ;
                               If( ( f := AScan( oBrwO:aSelected, oBrwO:BookMark ) ) == 0, ;
                               AAdd( oBrwO:aSelected, oBrwO:BookMark ), ;
                               ADel( oBrwO:aSelected, f, .t. ) ), nil ), ;
                               oBrwO:RefreshCurrent() }
    END


Needless to say that with previous version of FiveWin it did work. Surely is something simple that changed between versions, but I cannot seem to find what is it.

Thanks
Emiliano Llano Díaz
ellano
 
Posts: 107
Joined: Tue Sep 15, 2009 7:52 am

Re: checkbox on xBrowse with surplus info

Postby nageswaragunupudi » Tue Oct 09, 2018 6:43 pm

Needless to say that with previous version of FiveWin it did work. Surely is something simple that changed between versions,

Nothing changed.

The code posted above does not exactly correspond to the image posted. Also the above code (without any other additions or modifications) cannot produce that garbled image. Your original code could be somewhat different which produced that result.

As it is not possible to compile and build your code at our end, I provide here a similar code, with minor modifications.
Code: Select all  Expand view  RUN
#include "fivewin.ch"

function Main()

   local oDlg, oBrw, aData

   USE STATES
   aData    := FW_DbfToArray()
   CLOSE STATES

   DEFINE DIALOG oDlg SIZE 400,400 PIXEL TRUEPIXEL

   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE aData ;
      COLUMNS .f., 1, 2  ;
      HEADERS " ", "CODE", "NAME" ;
      LINES NOBORDER

   WITH OBJECT oBrw:aCols[ 1 ] //oBrw:InsCol( 1 )
      :bEditValue := { || AScan( oBrw:aSelected, oBrw:BookMark ) > 0 }
      :SetCheck()
      :nHeadBmpNo := { || If( Len( oBrw:aSelected ) == oBrw:nLen, 1, 2 ) }
   END

   WITH OBJECT oBrw
      :nMarqueeStyle    := MARQSTYLE_HIGHLROW
      :lMultiSelect     := .f.
      :bClrSelFocus     := { || { CLR_BLACK, CLR_HGRAY } }
      :nStretchCol      := 3
      :aCols[ 1 ]:bClrSelFocus := { ||{  CLR_BLACK, CLR_WHITE } }
      :bLClicked        := { |r,c,f,oBrw| If( oBrw:MouseColPos( c ) == 1 , ;
                           If( ( f := AScan( oBrw:aSelected, oBrw:BookMark ) ) == 0, ;
                           AAdd( oBrw:aSelected, oBrw:BookMark ), ;
                           ADel( oBrw:aSelected, f, .t. ) ), nil ), ;
                           oBrw:RefreshCurrent() }
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED

return nil
 


This part of the code
Code: Select all  Expand view  RUN

   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE aData ;
      COLUMNS .f., 1, 2  ;
      HEADERS " ", "CODE", "NAME" ;
      LINES NOBORDER

   WITH OBJECT oBrw:aCols[ 1 ] //oBrw:InsCol( 1 )
 

can also be written this way:
Code: Select all  Expand view  RUN

   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE aData ;
      COLUMNS 1, 2  ;
      HEADERS "CODE", "NAME" ;
      LINES NOBORDER

   WITH OBJECT oBrw:InsCol( 1 )
 


Both produce the same result:

Image
Regards

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

Re: checkbox on xBrowse with surplus info

Postby ellano » Wed Oct 10, 2018 11:51 am

Mr. Nages:

If you make this simple modification to your program you get something similar:

...
oBrw:SetArray(aData)
WITH OBJECT oBrw:InsCol( 1 )
:bEditValue := { || AScan( oBrw:aSelected, oBrw:BookMark ) > 0 }
...

Of course, I corrected my program deleting the offending lines ( oBrwO:aCols := {} and oBrwO:SetArray( aOrigen ) ) and changing them with a single oBrwO:aArrayData:= aOrigen


Code: Select all  Expand view  RUN
   oBrwO:aArrayData:= aOrigen  //needed since the user filters the DB that creates the array using several conditions
    WITH OBJECT oBrwO:aCols[ 1 ]
      :bEditValue    := { || AScan( oBrwO:aSelected, oBrwO:BookMark ) > 0 }     // Check list on column 1
      :SetCheck()
      :nHeadBmpNo    := { || If( Len( oBrwO:aSelected ) == oBrwO:nLen, 1, 2 ) } // image to use
    END


and the problem disappears. The mystery is still there: it passed unperceived during several years in previous FiveWin version working correctly :?:

Thank you for your time and valuable advises
Emiliano Llano Díaz
ellano
 
Posts: 107
Joined: Tue Sep 15, 2009 7:52 am

Re: checkbox on xBrowse with surplus info

Postby nageswaragunupudi » Wed Oct 10, 2018 12:06 pm

Please do not use SetArray( aData ) again. This method is intended to be called only once while creation of the browse.

When defining XBROWSE, please specify the array as DATASOURCE aData. This command calls SetArray( aData ) at the right time.

We again request to specify the ArrayData in the XBROWSE command only but not use SetArray() directly. This enables how to treat the column definitions while preparing the xbrowse.

Even this is not necessary
Code: Select all  Expand view  RUN
oBrwO:aArrayData:= aOrigen

Instead, please specify DATASOURCE aOrigen inside the REDEFINE XBROWSE command.

If you want to change the array at runtime (not before), set oBrw:aArrayData := <aNew>, but please do not use SetArray( aData ).

Calling SetArray() after the browse is prepared ( by Adjust() method) may have undesirable effects like this. This recommendation applies to other methods like SetRDD(), etc.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10662
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 64 guests