Page 1 of 2

Picture in dcbrowseol

Posted: Wed Jun 23, 2010 9:41 am
by BruceN
Is there a way to have a different picture clause for cells in a single column in a dcbrowse? We have a numeric field that sometimes needs to have decimals and other times needs to be integral in both view and edit. Thanks.

Re: Picture in dcbrowseol

Posted: Wed Jun 23, 2010 3:20 pm
by rdonnay
Use the PICTURE '999999.99' clause on the numeric column.

Re: Picture in dcbrowseol

Posted: Wed Jun 23, 2010 3:41 pm
by BruceN
Roger, I don't think you understood what I'm trying to do. I need to have some cells with 99999.99 and some with just 99999 based on the value of another field in the browse which determines whether the item is supposed to be an integer or a decimal, so I need the picture to evaluate the value of the other field in order to know whether it should be 99999.99 or 99999. Can that be done?

Re: Picture in dcbrowseol

Posted: Wed Jun 23, 2010 5:52 pm
by bwolfsohn
bruce,

try picture {||iif(condition,"999999.99","999999")}

Brian

Re: Picture in dcbrowseol

Posted: Thu Jun 24, 2010 5:00 am
by BruceN
I had already tried a codeblock as follows:

DCBROWSECOL ELEMENT 6 HEADER "Qty" PARENT oBrowse;
ID 'FIRST';
EDITOR 'IQTY';
PICTURE{||iif(svc_test(cVar]),'99999.99','99999')};
WIDTH 8

@ nil, nil dcget xNil GETID 'IQTY';
PICTURE{||iif(svc_test(cVar]),'99999.99','99999')};
lostfocus {|a,b,oGet|iif(oget:get:changed,sale_keys(xbeK_SH_F3,nChoice,lEdit),nil),;
line_calc( aArray, nChoice, @m_line_tot),;
oBrowse:RefreshAll()}

function svc_test(cVar)
ret_val:=.f.
if at(cVar,'HRS;HR ')>0
ret_val:= .t.
endif
return ret_val

So, if svc_test returns .t., then I should have 99999.99, otherwise I should get 99999. What happens is the entire column will format with the picture setting for whatever item it looked at last; it is not being evaluated line by line. So, if the first line returns .t., all lines will show 99999.99; if then I open up the editor on a line that returns .f., all lines then change to show 99999.

What our customer has is some inventory items that are sold as eaches (1, 2, 10, whatever) and other items that are sold in decimals (1.25, 1.5, etc.) and they want the editing grid to show the correct format so their employees cannot sell items in the wrong units (you can't sell 1.3 computers, but they can sell 1.5 hrs of onsite time). Hope I'm making sense.

Re: Picture in dcbrowseol

Posted: Thu Jun 24, 2010 5:25 am
by TWolfe
Hi Bruce,

The PICTURE must be a detached code block if you want it to react to dynamic cell data.

Terry

Re: Picture in dcbrowseol

Posted: Thu Jun 24, 2010 6:13 am
by BruceN
Can you provide me an example of what you mean by detached code block?

Re: Picture in dcbrowseol

Posted: Thu Jun 24, 2010 9:02 am
by skiman
Hi,

Why don't you use the dcbrowsecolumn data ... clause?

Your data can be a codeblock and returns what you want to show?

Re: Picture in dcbrowseol

Posted: Thu Jun 24, 2010 9:06 am
by skiman
BruceN wrote: DCBROWSECOL ELEMENT 6 HEADER "Qty" PARENT oBrowse;
ID 'FIRST';
EDITOR 'IQTY';
PICTURE{||iif(svc_test(cVar]),'99999.99','99999')};
WIDTH 8
What is your cVar?

Re: Picture in dcbrowseol

Posted: Thu Jun 24, 2010 11:23 am
by BruceN
cVar is the item type that gets sent to the function to determine if it should be decimal or not.