how to ajax refresh atklistattribute or atkmultiselect ?
i have atklistattribute or atkmultiselect attributes which are based on code/description arrays and these arrays are populated based on a query which involves a query based on value of a user selected column.
Say AtkList of Designations shown depend on the division selected by the user.
Then how to Ajax/Refresh ie AddDependee/Dependency refresh the atklist
Loose code / prototype is given belwo - it is NOT working - just to clarify what i wish to do
Code:
:
$division = &$this->add(new atkListAttribute("division",$divn_nm,$divn_cd,AF_HIDE_LIST|AF_OBLIGATORY));
$division->addDependency(array($this, "divnDependency"));
global $desg_cd;
global $desg_nm;
$designrow = $db->getrows("SELECT DISTINCT designation FROM organogram ");
for ($qcnt=0; $qcnt < count($designrow); $qcnt++)
{
$desg_cd[$qcnt] = $designrow[$qcnt]['designation'];
$desg_nm[$qcnt] = $designrow[$qcnt]['designation'];
}
$this->add(new atkMultiSelectAttribute("designation",$desg_cd,$desg_nm,5,AF_CHECK_ALL|AF_LINKS_BOTTOM|AF_HIDE_LIST);
:
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
function divnDependency(atkEditFormModifier $modifier)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
{
$record = &$modifier->getRecord();
if ($modifier->isInitial()) return;
global $desg_cd;
global $desg_nm;
$db = &atkGetDb();
$designrow = $db->getrows("SELECT DISTINCT designation FROM organogram where divn = '" . $record['division'] . "'");
for ($qcnt=0; $qcnt < count($designrow); $qcnt++)
{
$desg_cd[$qcnt] = $designrow[$qcnt]['designation'];
$desg_nm[$qcnt] = $designrow[$qcnt]['designation'];
}
$modifier->refreshAttribute('designation');
} //function divnDependency()