Re: DataGrid and DataObject Links
| From: | Ken Restivo | Date: | Mon, 20 Dec 2004 03:41:34 +0000 |
| Subject: | Re: DataGrid and DataObject Links | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-16334@lists.php.net to get a copy of this message | ||
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Sat, Dec 18, 2004 at 10:28:52AM -0800, Justin Patrin wrote:
> On Sat, 18 Dec 2004 13:16:26 +0100, Rodrigo Alvarez <papipo@gmail.com> wrote:
> > Hi PEARs,
> >
> > I want to know if Structures_DataGrid supports DataObject crossLinks.
> > I can joinAdd() a DO to another, and then bind it to a datagrid.
> > But I believe that I obtain ids, not link-fields.
> >
>
> You're getting a bit ahead of yourself there. DataGrid is for showing
> record and I *believe* the new version makes use of some FormBuilder
> options, but it doesn't AFAIK use FormBuilder itself, so it won't
> support crossLinks or any of the other wonderful options FormBuilder
> has. I would recommend *against* this, actually, as it would put code
> to handle the same thing in two different packages.
>
I've duplicated a subset of code in my package to display crosslinks using HTML_Table. I
didn't want or need to include all of FB. I'm making use of the $fb_ options in the DBDO
in order to do this. I'm not fishing out the whole range of options for a select box as FB
does, just the one that corresponds to this record:
function concatLinkFields(&$obj)
{
$ldfs = $obj->fb_linkDisplayFields;
if(!$ldfs){
return $val;
}
//confessObj($obj, "concatlinkfields(obj)");
// only if i have linkfields in the dataobj
$val = false; // gotta reset it here.
foreach($ldfs as $linkfield){
// trying to YAGNI here. i don't need 2-level links yet
if($obj->$linkfield){
$val .= sprintf("%s%s", $val ? ' - ' : "",
$obj->$linkfield);
}
}
return $val;
}
So for each field I display in my HTML_Table, I just:
$links = $this->links();
$subobj = $this->getLink($this_key);
$this->concatLinkFields(&$subobj);
- -ken
- --
- ---------------
The world's most affordable web hosting.
http://www.nearlyfreespeech.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
iD8DBQFBxknue8HF+6xeOIcRAoIjAKDTv9CD2mG+feW9a3/6ZgzBXA1sQwCfd1a/
NZusFhIOmfxTowur+eAd98w=
=ho1K
-----END PGP SIGNATURE-----