Re: One more question: hidden datagrid columns

From: Date: Sun, 08 Jun 2008 12:50:48 +0000
Subject: Re: One more question: hidden datagrid columns
References: 1 2 3 4  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-28995@lists.php.net to get a copy of this message
Olivier Guilyardi schrieb:
Bernhard, please: 1 - answer on the list 2 - answer in the body of the mail, not at the top. Bernhard Harb a écrit :
Thanks a lot! Any idea, if there is a chance to get the value of a hidden column with smarty renderer? I think smarty gets only the visible columns - does it?
Well, I'm afraid you can't do that, because of the way SDG tries to separate presentation from data. Post a feature request if you like. However, I suspect all you need is a column formatter, where you can access all of the data. For example, to make a link: function makeLink($data) { $id = $data['record']['id']; $name = htmlspecialchars($data['record']['name']); return "<a href=\"show.php?id=$id\">$name</a>"; } $datagrid->generateColumns(array('name' => 'Name', 'phone' => 'Phone number')); $datagrid->getColumnByField('name')->setFormatter('makeLink'); $datagrid->bind('SELECT id, name, phone FROM addressbook'); This way you'll get clickable names. Regards, -- Olivier Ok, I got a way how to manage it. I added each column I want to access but I do not want to show at the end of the column list and then I do a $datagrid->fill($smarty)
In my Smarty template I do a {foreach} on every row and column and then I check the columncounter inside each row and only print the column if it is less then a specific value. Of course, thats not the best way but I think it's the only way to separate logic code and presentation code. Cheers, Bernhard.

« previous php.pear.general (#28995) next »