How to Focus on a MVC Component

Asked

Viewed 1,645 times

2

I have a MVC model 3.

After validation of a header field(formfield), set the focus to the grid.

How to do this?

2 answers

3

It is not recommended to refresh the view within a model validation. Therefore, it is correct to use the VIEW’s own mechanisms: in the viewdef....

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

To set the focus on the Grid:

Static function MinhaAcao(oView,cIDView,cField,xValue)
Local oGrid := oView:GetviewObject(cIDVIEW)
oGrid:SetFocus()
return
  • It’s nice to see other languages around here, but I think I could add to the post by putting a slightly larger context (both in the answer and in the question, like mentioning when Fieldaction will run codeblock, for example). Although I am familiar with xbase dialects, do not use Advpl, the method is Getviewobject even? I found it kind of redundant.

  • Opa I am trying to spread the use of stackoverflow in the advpl community, I will try to give a bigger context. The method is this same.

0

In case you haven’t solved it, Voce needs to be the code block on bGotFocus of

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

In the bGotFocus I did the stretch below, like this whenever the Grid get the focus it goes back to the field I want, with this I created a control variable for the same.

oView:Refresh()
oView:GetViewObj("FIELDZZ5")[3]:getFWEditCtrl("ZZ5_QUANT"):oCtrl:SetFocus()
  • 1

    His answer brought me more doubts than explanations. For example, what would be ZZ5? What this influences on grid any of a MVC 3 system? Killerall’s response, however, even in its simplicity and succinccy to the extreme, managed to explain a lot to me

  • Sorry the way I answered, ZZ5 is the table I use, I will change the explanation.

  • oView:Refresh() oView:Getviewobj("DATA MODEL")[3]:getFWEditCtrl("FIELD THAT WILL RECEIVE THE FOCUS"):oCtrl:Setfocus()

Browser other questions tagged

You are not signed in. Login or sign up in order to post.