Grouping attributes into two columns (ATK 6.4)
From Achievo/ATK Wiki
|
ATK Howto: Grouping attributes into two columns (ATK 6.4)
|
Requirements
ATK 6.4
Summary
As of the ATK 6.4 official release after Oct 26, 2009, there is a new way to add attributes into two columns. This howto walks you through the process.
Procedures
By default attributes are position on one single column in ATK. To position attributes on the right column you will need to call the following new method within your node:
$attribute->setColumn(1)
This method will position the given attribute to the right column of the node, to make a two column layout.
Assuming you had the following node:
function employee() { $this->atkNode("employee", NF_ADD_LINK);// $this->add(new atkAttribute("id", AF_AUTOKEY)); $this->add(new atkAttribute("name", AF_OBLIGATORY|AF_UNIQUE|AF_SEARCHABLE)); $this->add(new atkManyToOneRelation("department_id","lesson3.department", AF_SEARCHABLE)); $this->add(new atkManyToOneRelation("manager_id","lesson3.employee", AF_SEARCHABLE|AF_RELATION_AUTOCOMPLETE)); $this->add(new atkDateAttribute("hiredate")); $this->add(new atkNumberAttribute("salary", AF_TOTAL)); $this->add(new atkTextAttribute("notes", 0, AF_HIDE_LIST)); $this->setOrder("name"); $this->setIndex("name"); $this->setTable("lesson3_employee"); }
To display the attributes, name, salary and hiredate on the right column, you would need to modify your node to include the following:
$this->add(new atkDateAttribute("hiredate"))->setColumn(1); $this->add(new atkNumberAttribute("salary", AF_TOTAL))->setColumn(1); $this->add(new atkTextAttribute("notes", 0, AF_HIDE_LIST))->setColumn(1);
So your final code would look as follows:
function employee() { $this->atkNode("employee", NF_ADD_LINK);// $this->add(new atkAttribute("id", AF_AUTOKEY)); $this->add(new atkAttribute("name", AF_OBLIGATORY|AF_UNIQUE|AF_SEARCHABLE)); $this->add(new atkManyToOneRelation("department_id","lesson3.department", AF_SEARCHABLE)); $this->add(new atkManyToOneRelation("manager_id","lesson3.employee", AF_SEARCHABLE|AF_RELATION_AUTOCOMPLETE)); $this->add(new atkDateAttribute("hiredate"))->setColumn(1); $this->add(new atkNumberAttribute("salary", AF_TOTAL))->setColumn(1); $this->add(new atkTextAttribute("notes", 0, AF_HIDE_LIST))->setColumn(1); $this->setOrder("name"); $this->setIndex("name"); $this->setTable("lesson3_employee"); }
Until next time,
[Jorge Garifuna http://www.GariDigital.com]