How to Set Focus on an MVC Component

1

I have a MVC template 3.

After validating a header field ( formfield ), set focus to grid .

How to do this?

    
asked by anonymous 31.08.2016 / 00:17

2 answers

2

It is not recommended to refresh the view within a template validation. Therefore the correct one is to use the mechanisms of the VIEW itself: in viewdef ....

bBloco := {|oV,cId,cField,xV|MinhaAcao(oV,cId,cField,xV)}
oView:SetFieldAction("CAMPO",bBloco)

To focus on the Grid:

Static function MinhaAcao(oView,cIDView,cField,xValue)
Local oGrid := oView:GetviewObject(cIDVIEW)
oGrid:SetFocus()
return
    
31.08.2016 / 00:18
0

If you have not solved it, you need to be the code block in bGotFocus da

FWFORMVIEW():AddGrid(<cViewID >, <oStruct >, [ cSubModelID ], <uParam4 >, [ bGotFocus ])

No bGotFocus I made the following section, like this whenever the Grid gets the focus it returns to the field I want, so I created a control variable for it.

oView:Refresh()
oView:GetViewObj("FIELDZZ5")[3]:getFWEditCtrl("ZZ5_QUANT"):oCtrl:SetFocus()
    
15.11.2018 / 03:15