Jump to content

AtkTreeNode: Difference between revisions

From NusaATK
despam
m removed duplicated title
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
'''AtkTreeNode''' should be used together with [[atkManyToOneTreeRelation]] to create a child : parent tree.


[[Image:Atktreenode.png]]
== How to use ==
* do import AtkTreeNode:
atkimport("atk.atktreenode");
* on [[atkManyToOneTreeRelation]] do use [[ATK_Attribute_Flags|AF_PARENT]]
* do not forget to call $this->atkTreeNode instead of $this->atkNode
== Example ==
<?php
atkimport("atk.atktreenode");
userelation("atkManyToOneTreeRelation");
class categoria extends atkTreeNode
{
    function categoria()
    {
      $this->atkTreeNode("categoria", NF_ADD_LINK);
   
      $this->add(new atkAttribute("categoria_id", AF_AUTOINCREMENT|AF_PRIMARY|AF_HIDE_ADD|AF_HIDE_EDIT|AF_HIDE_LIST));
   
      $this->add(new atkAttribute("categoria_nome", AF_SEARCHABLE));
   
       
      $this->add(new atkManyToOneTreeRelation("categoria_pai", "diretorio.categoria",
        AF_PARENT
      ));
   
      $this->setOrder("categoria_nome ASC");
      $this->setTable("diretorio_categoria");
    }
   
   
    function descriptor_def()
    {
      return "[categoria_nome]";
    }
}
?>

Latest revision as of 02:17, 28 December 2006

AtkTreeNode should be used together with atkManyToOneTreeRelation to create a child : parent tree.

How to use

  • do import AtkTreeNode:
atkimport("atk.atktreenode"); 


Example

<?php
atkimport("atk.atktreenode"); 
userelation("atkManyToOneTreeRelation");

class categoria extends atkTreeNode
{
   function categoria()
   {
     $this->atkTreeNode("categoria", NF_ADD_LINK);
   
     $this->add(new atkAttribute("categoria_id", AF_AUTOINCREMENT|AF_PRIMARY|AF_HIDE_ADD|AF_HIDE_EDIT|AF_HIDE_LIST));
   
     $this->add(new atkAttribute("categoria_nome", AF_SEARCHABLE));
    
       
     $this->add(new atkManyToOneTreeRelation("categoria_pai", "diretorio.categoria",
       AF_PARENT
     ));
   
     $this->setOrder("categoria_nome ASC");
     $this->setTable("diretorio_categoria");
   }
   
   
   function descriptor_def()
   {
     return "[categoria_nome]";
   }
}
?>