Again, I am struggling to program xBrowse to be able to edit a cell based on a field in a table. Using this snipit of code I am able to paint the Listbox and the columns edit correctly based on the field 'LockedDown' but when you append a new record the columns that were created as not editable should now be editable based on the If statement and the nEditType code block.
Here is the snipit of code .. again, appending a new record flagging the 'LockedDown' field does not change the nEditType block at runtime ..
As you can see in the AddNewRecord function .. I am refreshing the browse and setting the new appended field 'LockedDown' to .f. .. The blue color designates the column was not editable when the browse was painted ..
Rick Lipkin
- Code: Select all Expand view
// row number
oLbxB:aCols[1]:nEditType := EDIT_NONE
// qty
oLbxB:aCols[2]:nEditType := If( oRsDetail:fields("LockedDown"):Value = .t., EDIT_NONE, EDIT_GET )
// part number
oLbxB:aCols[3]:nEditType := If( oRsDetail:fields("LockedDown"):Value = .t., EDIT_NONE, EDIT_GET )
oLbxB:aCols[3]:bOnPostEdit := {|o,v| _InvtLookUp( v, oRsDetail ) }
// type
oLbxB:aCols[4]:nEditType := If( oRsDetail:fields("LockedDown"):Value = .t., EDIT_NONE, EDIT_GET )
// description
oLbxB:aCols[5]:nEditType := If( oRsDetail:fields("LockedDown"):Value = .t., EDIT_GET, EDIT_NONE )
oLbxB:aCols[5]:bEditValue := { || alltrim(oRsDetail:Fields("Item Description"):Value)+space(25) }
oLbxB:aCols[5]:bOnPostEdit := {|o,v| _GetText( v,oLbxB ) }
// Price
oLbxB:aCols[6]:nEditType := If( oRsDetail:fields("LockedDown"):Value = .t., EDIT_NONE, EDIT_GET )
// ext
oLbxB:aCols[7]:nEditType := EDIT_NONE
// color the columns
oLbxB:oCol( "Qty" ):bClrStd := {|| {if(oRsDetail:fields("LockedDown"):Value = .t., CLR_HBLUE, CLR_BLACK), CLR_WHITE } }
oLbxB:oCol( "Part Number" ):bClrStd := {|| {if(oRsDetail:fields("LockedDown"):Value = .t., CLR_HBLUE, CLR_BLACK), CLR_WHITE } }
oLbxB:oCol( "Type" ):bClrStd := {|| {if(oRsDetail:fields("LockedDown"):Value = .t., CLR_HBLUE, CLR_BLACK), CLR_WHITE } }
oLbxB:oCol( "Ext" ):bClrStd := {|| {if(oRsDetail:fields("LockedDown"):Value = .t., CLR_HBLUE, CLR_BLACK), CLR_WHITE } }
// add a new record
oLbxB:bPastEof = {|| _AddNewRow( oRsDetail,nRepairNumber,nAssignedTo,cLoc,oLbxB ) }
...
...
//----------------
Static Func _AddNewRow( oRsDetail,nRN,nTech,cLocation,oBrw )
Local Saying
Saying := "Do you wish to Add a New Record ?"
If MsgYesNo( Saying )
Else
Return(.f.)
Endif
oRsDetail:AddNew()
oRsDetail:Fields("Repair Number"):Value := nRn
oRsDetail:Fields("Repair Detail Line"):Value := 0
oRsDetail:Fields("Qty"):Value := 1
oRsDetail:Fields("Item Description"):Value := space(255)
oRsDetail:Fields("Price"):Value := 0
oRsDetail:Fields("Tech Number"):Value := nTech
oRsDetail:Fields("Inventory Id"):Value := space(50)
oRsDetail:Fields("Inventory Type"):Value := space(50)
oRsDetail:Fields("Cost"):Value := 0
oRsDetail:Fields("Covered By Warranty"):Value := .f.
oRsDetail:Fields("Location"):Value := cLocation
oRsDetail:Fields("Code"):Value := space(50)
oRsDetail:Fields("Shipping Ref"):Value := space(64)
oRsDetail:Fields("Serial Number"):Value := space(50)
oRsDetail:Fields("NoTax"):Value := 0
oRsDetail:Fields("Warranty Provider"):Value := space(50)
oRsDetail:Fields("Quote Price"):Value := 0
oRsDetail:Fields("LockedDown"):Value := .f.
oRsDetail:Update()
oBrw:ReFresh()
oBrw:nColsel(2)
oBrw:SetFocus()
xMode := "A"
Return(.t.)