Static Function ModelDef()
Local oModel
Local oStruZA1:= FWFormStruct(1,'ZA1')
Local oStruZA2 := FWFormStruct( 1, 'ZA2')
Local bLinePre := {|oGridModel, nLine, cAction, cIDField, xValue, xCurrentValue| linePreGrid(oGridModel, nLine, cAction, cIDField, xValue, xCurrentValue)}
Local bLoad := {|oGridModel, lCopy| loadGrid(oGridModel, lCopy)}
oModel := MPFormModel():New('COMP021')
oModel:AddFields('ZA1MASTER',,oStruZA1)
oModel:AddGrid( 'ZA2DETAIL', 'ZA1MASTER', oStruZA2, bLinePre, , , ,bLoad)
Return oModel
Static Function loadGrid(oGridModel, lCopy)
Local aLoad := {}
aAdd(aLoad,{0,{xFilial("ZA2"), "000001", "01", "000100","AUTOR1","AUTOR"}})
aAdd(aLoad,{0,{xFilial("ZA2"), "000001", "02", "000102","AUTOR2","AUTOR"}})
aAdd(aLoad,{0,{xFilial("ZA2"), "000001", "03", "000104","AUTOR3","AUTOR"}})
aAdd(aLoad,{0,{xFilial("ZA2"), "000001", "04", "000105","AUTOR4","AUTOR"}})
aAdd(aLoad,{0,{xFilial("ZA2"), "000001", "05", "000106","AUTOR5","AUTOR"}})
Return aLoad
Static Function linePreGrid(oGridModel, nLine, cAction, cIDField, xValue, xCurrentValue)
Local lRet := .T.
If cAction == "SETVALUE"
If oGridModel:GetValue("ZA2_TIPO") == "AUTOR"
lRet := .F.
Help( ,, 'HELP',, 'Não é possível alterar linhas do tipo Autor', 1, 0)
EndIf
EndIf
Return lRet