Re: HTML_Table and altrowattributes
| From: | Wes Rood | Date: | Thu, 20 May 2004 03:08:25 +0000 |
| Subject: | Re: HTML_Table and altrowattributes | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-12643@lists.php.net to get a copy of this message | ||
Bertrand Mansion wrote:
Wes Rood wrote:My simple solution will be to create a wrapper object around the html_table, exposing the methods of html_table I desire (namely addrow), and providing a tohtml method that will just call altrowattributes before calling toHtml on the "wrapped" html_table. I just wanted to bring up the idea of changing html_table - but I realize now after thinking it over more that it would probably be a big design change.I am using a lot of tables in my application, so I wanted to be able to pull out the creation of the table and heading into a separate method. I will then call this method to get the table object and just add rows and call toHtml(). This works fine, except that I'd really like to also move the setting of the alternate row attributes into this method as well. The problem is that it only works if you call it *after* adding the rows to the table, not before. To get it to work this way, the altrowattributes method would just save off the desired attributes, then use them as rows were added to the table (every other one, of course). To maintain backwards compatibility, it would probably have to be a new method, so it wouldn't break for people currently calling altrowattributes after adding the rows. Please let me know if this is a possible enhancement.Why can't you call altRowAttributes when you are finished filling the table ? Bertrand Mansion Mamasam It's not that I can't, I'm just suggesting that the setting of the alternate row attributes be considered similiar to the things one does upon construction of the html_table object. And that the adding of rows is something that is done *after* the table is all set up. I'd like to move all the setup code into a method (for reuse), then the many places that I'm building tables would simply have to call that method, add rows, then call tohtml() without having to remember to call altrowattributes.