Page 1 of 1

xBrowse Image on inserted column

Posted: Tue Jul 29, 2008 1:33 am
by fraxzi
Hello all!

I have this xbrowse which load the table and all fields are displayed accordingly...

I inserted below code and wanted to display the image depending on the value of :bEditValue...

Code: Select all

            ...
            oBrwPIC:InsCol( 2 ) 
            oBrwPIC:aCols[2]:bEditValue := {|e| IF(e == Nil, 1, e) }
            oBrwPIC:aCols[2]:addResource( 'checkbox16' )
            oBrwPIC:aCols[2]:addResource( 'crossbox16' )
            oBrwPIC:aCols[2]:bBmpData := {|| Eval(oBrwPIC:aCols[2]:bEditValue) }
            oBrwPIC:aCols[2]:bLDClickData := {|x| x := Eval(oBrwPIC:aCols[2]:bEditValue),;
                                                  IF( x == 1, Eval(oBrwPIC:aCols[2]:bEditValue, 2),;
                                                              Eval(oBrwPIC:aCols[2]:bEditValue, 1) ),;
                                                  oBrwPIC:RefreshCurrent() }
            ...

How can I switch :bEditValue from 1 to 2 and vice-versa by double-clicking on the column?

If the inserted column is a field, it would not be the problem... but with the inserted column, i'm in trouble. :lol:


'Appreciate any help.


Regards,

Posted: Tue Jul 29, 2008 3:06 am
by nageswaragunupudi

Code: Select all

// These commands can be used even when the browse is running
// if the datasource is dbf

ADD oCol TO oBrwPIC AT 2 DATA FIELDWBLOCK( <fldname>, <nSelectArea> ) ;
HEADER 'Pic' ;
BITMAP FIELD-><fldname> IN 'checkbox16', 'crossbox16'

// If the datasource is array

ADD oCol TO oBrwPIC AT 2 ARRAY ELEM <nColNo>
HEADER 'Pic' ;
BITMAP FIELD-><fldname> IN 'checkbox16', 'crossbox16'

// if the column is inserted after the browse is already displayed and running, we need to add oBrwPIC:Refresh() after adding column


oCol:bLDClickData := { || oCol:Value := If( oCol:Value == 1, 2, 1 ), oBrwPIC:RefreshCurrent() }


Posted: Tue Jul 29, 2008 5:27 am
by fraxzi
Thank you for the reply NageswaraRao,

The datasource is RDD but the inserted column is kinda 'raw' but not a field... it is only to hold the value for the display of bitmap.

regards,

Posted: Tue Jul 29, 2008 9:18 am
by fraxzi
HELP! :oops:




Regards,

Posted: Tue Jul 29, 2008 11:17 am
by nageswaragunupudi
>
nserted column is kinda 'raw' but not a field.
>

What is the variable you want to be changed when the coumn is double clicked?

Posted: Tue Jul 29, 2008 11:22 am
by nageswaragunupudi
As I do not what exactly is in your mind I give here an example. Column 2 is insereted. Column 2 shows bitmaps 1 by default. If user double clicks the bitmaps are toggled. You may use this logic to suit your needs.

Code: Select all

func atest

   local oWnd, oBrw, oCol
   local aNums

   use customer
   aNums := Array( LastRec() )
   AFill( aNums, 1 )

   define window ownd
   @ 0,0 xbrowse obrw ;
      columns 'Last', 'City', 'State' ;
      of ownd ;
      alias 'customer'


   oCol  := oBrw:InsCol( 2 )
   oCol:bBmpData     := { || aNums[ RecNo() ] }
   oCol:bLDClickData  := { || aNums[ RecNo() ] := If (aNums[ RecNo() ] == 1, 2, 1 ), oBrw:RefreshCurrent() }
   oCol:AddResource( 'Open' )
   oCol:AddResource( 'Close' )

   obrw:createfromcode()
   ownd:oclient := obrw

   activate window ownd

return nil

Posted: Tue Jul 29, 2008 11:35 am
by fraxzi
Mr. NageswaraRao,

I think this is what i'm missing... 'variable (array equal the the lenght of table) that will replace the field in xBrowse column...

...
aNums := Array( LastRec() )
AFill( aNums, 1 )
...
Clever idea. I never thought of that :roll:


Will let you know after dinner (i'm on the other side of the world ) :D

Posted: Tue Jul 29, 2008 11:47 am
by nageswaragunupudi
>
(i'm on the other side of the world )
>

I am also on the same side as you are. Just 2 1/2 hours later than you

Posted: Tue Jul 29, 2008 12:04 pm
by fraxzi
:P :P :P


It worked great :!: like magic :!:



Thank you so much and regards,