f



Making bBrowser cells editable or non-editable dynamically

I wish to make a given cell in Column 2 of my bBrowser editable non-editabl=
e (and perhaps color it differently), based on the value of the cell in the=
 same row of Column 1.  I'm testing the value of the criterion cell in my C=
ellEdit method, in the BEDIT_HIDE branch for Column 1, but=20

   bBrowser:GetColumn(2):editable =3D .f.

doesn't seem to do the trick.  And I'm not at all sure about coloring cells=
 one-by-one.  Any suggestions?
0
rkaplan328
11/5/2016 12:37:30 AM
comp.clipper.visual-objects 12618 articles. 0 followers. Post Follow

7 Replies
297 Views

Similar Articles

[PageSpeed] 29

Replying on message of Fri, 4 Nov 2016 17:37:30 -0700 (PDT) from
rkaplan328:


 Hello rkaplan328

Can you give your real name?

This is what you can do. On the init of the browser, add:

	SELF:oDCbBrowserControl:Editable:=TRUE

In this method you determine when or when not to allow editing. In the
code below, this is based on the fieldname or fieldtype of the whole
column. But it should be not too difficult to vary. Also note that
there are some excellent samples shipped with bBrowser, which include
code like this.

METHOD CellEdit(oCellEditEvent) CLASS IndexPercVenster
LOCAL oColumn		AS bDataColumn
LOCAL cFieldname AS STRING
LOCAL nField AS LONGINT

	oColumn := oCellEditEvent:Control:GetOpenColumn
(oCellEditEvent:EditCell:Column)
	IF oCellEditEvent:EditMode == BEDIT_CREATE
		DO CASE
		CASE oColumn:ValType="L" // Checkboxes (logical
fields) can be edited directly
			RETURN TRUE
		CASE oColumn:NameSym == #SOMEFIELD
			RETURN TRUE
		OTHERWISE
			RETURN FALSE
		ENDCASE
	ENDIF
	IF oCellEditEvent:EditMode == BEDIT_COMMIT
		oCellEditEvent:Control:Server:Commit()
		nField:=oColumn:FieldNo
		cFieldname:=oColumn:FieldName
	ENDIF

RETURN TRUE

Dick
0
D
11/5/2016 8:13:52 AM
Dick,
Thank you for your help.
I will try, later today, adapting your code to my specific situation and let you know how it goes.
Much appreciated!
Richard Kaplan
0
rkaplan328
11/5/2016 9:49:43 AM
Hi Richard,
In your define bbrowser you can add an edit condition to a column. This will make it NON-editable when the condition is true.

 oEditCondition := EditCondition{'Server:TYPE<>"N"',oServer,FALSE}
 bBrowser:GetColumn(2):EditCondition:Add(oEditCondition)

To make it Red when it is not Editable:
oColorCondition := ColorCondition{'Server:TYPE<>"N"',oServer,Color{COLORRED}}
oBrowser:GetColumn(2):ColorCondition:Add(oColorCondition)

Thats all.
0
Sjonnie
11/7/2016 3:03:56 PM
Sjonnie,
Thank you for your excellent suggestion.  I had not been aware of the EditC=
ondition facility which is parallel to the ColorCondition one.  So I now ha=
ve two pairs of statements in the definition of column 2 in my init method:

oColorCondition :=3D bColorCondition{{|x|x:Server:col1=3D1}, [color stuff] =
}
oColumn:ColorCondition:Add(oColorCondition)

and

oEditCondition1:=3DbEditCondition{{|x|x:Server:col1=3D1},self:oDCbBrowser1:=
Server,FALSE}
oColumn:EditCondition:Add(oEditCondition)=20

Now this works fine when I've just made an entry in col 1, i.e., if I've en=
tered a 1 column 2 becomes non-editable.  But when I move around the bBrows=
er1, the color condition on col 2 remains intact, but the edit condition se=
ems to get lifted.  Do you have any idea what I am doing wrong?
0
rkaplan328
11/7/2016 10:43:52 PM
Turns out that 
bEditCondition{{|x|x:server:col1=whatever},...} does not work but
bEditCondition{     "server:col1=whatever",...} works just fine.
No similar problem with bColorCondition.
0
rkaplan328
11/8/2016 7:20:13 AM
Look at every sample of celledit you can find.

You will find that returning false from it will prevent editing

Celledit callback method is extremely powerful and worth fully investigating

On 05/11/2016 00:37, rkaplan328 wrote:
> I wish to make a given cell in Column 2 of my bBrowser editable non-editable (and perhaps color it differently), based on the value of the cell in the same row of Column 1.  I'm testing the value of the criterion cell in my CellEdit method, in the BEDIT_HIDE branch for Column 1, but
>
>    bBrowser:GetColumn(2):editable = .f.
>
> doesn't seem to do the trick.  And I'm not at all sure about coloring cells one-by-one.  Any suggestions?
>

0
Martin
11/8/2016 9:12:04 AM
Richard,

this should work too:

{|Server, Column, Row, RecNo| server:col1=whatever}

Regards,

Joachim Bieler



Am 08.11.2016 um 08:20 schrieb rkaplan328:
> Turns out that
> bEditCondition{{|x|x:server:col1=whatever},...} does not work but
> bEditCondition{     "server:col1=whatever",...} works just fine.
> No similar problem with bColorCondition.

0
Joachim
11/9/2016 6:02:42 AM
Reply: