Árvore de páginas

Versões comparadas

Chave

  • Esta linha foi adicionada.
  • Esta linha foi removida.
  • A formatação mudou.

...

Bloco de código
titleExemplo de utilização do TreeView
linenumberstrue
collapsetrue
// definitionDeficoes do treeview
{utp/ut-4gltreeview.i}

PROCEDURE afterDisplayFields :
   RUN carregaTreeView.
   RUN criaTreeView.
END PROCEDURE.

// carregandoCarregando o componente treeview
PROCEDURE afterDisplayFieldscarregaTreeView :
    IF NOT VALID-HANDLE(h-4gltreeview) THEN DO:
      // instanciaInstancia o treeview
      RUN utp/ut-4gltreeview.w PERSISTENT SET h-4gltreeview.
   
      // Indica a Frame "Pai" do componente
      RUN setParentFrame IN h-4gltreeview (INPUT FRAME fPage0:HANDLE).

      // inicializaInicializa o treeview
      RUN initializeObject IN h-4gltreeview.
   
      // fazFaz a subscricao dos eventos do treeview
      SUBSCRIBE TO "tvNodeEvent" IN h-4gltreeview.

      // reposicionaReposiciona o treeview 
      RUN repositionObject IN h-4gltreeview (6.35, 2.00).

      // ajustaAjusta o tamanho do treeview 
      RUN resizeObject IN h-4gltreeview (10.70, 28.00).
   END.

   END PROCEDURE.

// carregaCria os itensnodes dono treeview
PROCEDURE criaTreeView :
 RUN pi-loadNodes.
 // Limpa o treeview
   RUN emptyTree IN h-4gltreeview NO-ERROR.
   ASSIGN c-codigo-node = "".

   // Logica para criar nos nodes do treeview
   ...
   RUN pi-create-node (cNodeId, cNodeIdPai, cDescNode, cImage, cOptn).
   ...

   // fazFaz o refresh do treeview
   RUN pi-atualizaTreeview.   

   // colocaColoca o cursor no treeview
   RUN applyEntry IN h-4gltreeview (INPUT "").
END PROCEDURE.

// esta procedure seraProcedure executada toda vez que ocorrer um evento de click em um determinado nónode
PROCEDURE pi-ClickTreeView :
   MESSAGE c-codigo-node VIEW_AS ALERT-BOX.
END PROCEDURE.

// retiraRetira o treeview da memoria
PROCEDURE beforeDestroyInterface :
   IF VALID-HANDLE(h-4gltreeview) THEN DO:
      RUN destroyObject IN h-4gltreeview.
      DELETE PROCEDURE h-4gltreeview.
   END.     

   RETURN "OK":U.
END PROCEDURE.

...