ooper
Junior Member
Posts: 6
Registered: 6/9/2005
Location: Utah
Member Is Offline
|
| posted on 6/15/2005 at 05:17 PM |
|
|
Server side components question
The code provided with the PRO version for dynamic creation of tree menu is great. I have a question though. When the user clicks on a node of the
tree menu in a browser, I want to be able to find out which row in the database that node corresponds to, i.e., the primary key column value in the
database. I can't rely on the caption, since it may not be unique.
During the dynamic creation of the tree menu, is there a way to stick the primary key value into each tree item somehow so that it can be used when
the user clicks on the tree item?
Thanks,
Brian Barnett
|
|
|
rock
Moderator
Posts: 687
Registered: 4/15/2003
Member Is Offline
|
| posted on 6/16/2005 at 08:13 AM |
|
|
Yes, it's not a big issue. You need to modify build_hierarchy function (items.php), instead section
...
echo " ['$row[$cfn]', \"javascript:linkCheck('$clink')\", ";
if($id == 0) echo "{'st':1}";
else echo "0";
build_hierarchy($cid, $vn, $tn, $idfn, $pidfn, $cfn, $lfn);
echo ']';
...
use something like:
...
echo "['$row[$cfn]', \"javascript:linkCheck('$clink')\", {'myDBid':$primaryKey}";
build_hierarchy($cid, $vn, $tn, $idfn, $pidfn, $cfn, $lfn);
echo ']';
...
Note that items get IDs ('myDBid') in the item scope settings. To read the item ID via javascript try:
...
var my_DB_id = o_item.a_config[2]['myDBid'];
//where o_item - tree_item object
...
|
|
|
|