PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
cakeFest
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Formatting of datagrid->render VS table->toHtml

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> Structures
View previous topic :: View next topic  
Author Message
mcmorris95125



Joined: 28 Jun 2008
Posts: 2

PostPosted: Sat Jun 28, 2008 10:29 pm    Post subject: Formatting of datagrid->render VS table->toHtml Reply with quote

The Structure_DataGrid docs "complex example" shows all of the HTML level formatting being done on the HTML_Table instance directly, rather than using the DataGrid_Renderer object functions. Then the output is done with the $table->toHtml() rather than with the $datagrid->render() function.

First Q: Why is this... Is using the HTMLTable functions preferred, or is this an artifact of old documentation not updated? Because it seems like (almost) all the formatting tools are in the Renderer classes.

Second Q: The one thing I can't figure out how to do via the HTML_Table_Renderer driver is assigning Table level attributes --- specifically a CSS class to the table element. I pass an array('class'=>'datagrid') to the new HTMLTable() constructor... and by using the table->toHtml(), the class is assigned. But if I use the datagrid->render(), I cannot get the class to show up. The Renderer has options to set headers, all cells, alternating rows, etc., but apparently no table level attribute??? Does this mean I must use toHtml() ??

Thanks in advance,

MCM
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 911

PostPosted: Mon Jun 30, 2008 12:38 am    Post subject: Re: Formatting of datagrid->render VS table->toHtml Reply with quote

mcmorris95125 wrote:
The Structure_DataGrid docs "complex example" shows all of the HTML level formatting being done on the HTML_Table instance directly, rather than using the DataGrid_Renderer object functions. Then the output is done with the $table->toHtml() rather than with the $datagrid->render() function.

First Q: Why is this... Is using the HTMLTable functions preferred, or is this an artifact of old documentation not updated? Because it seems like (almost) all the formatting tools are in the Renderer classes.


There are several such methods in the renderer for BC (backwards compatibility) reasons. The preferred way of "styling" the table is to use the HTML_Table methods directly (as shown in the manual -- which is, BTW, very up-to-date).

mcmorris95125 wrote:
Second Q: The one thing I can't figure out how to do via the HTML_Table_Renderer driver is assigning Table level attributes --- specifically a CSS class to the table element. I pass an array('class'=>'datagrid') to the new HTMLTable() constructor... and by using the table->toHtml(), the class is assigned. But if I use the datagrid->render(), I cannot get the class to show up. The Renderer has options to set headers, all cells, alternating rows, etc., but apparently no table level attribute??? Does this mean I must use toHtml() ??


Yes, you're right. We won't add any new HTML_Table methods to the renderer in the future, as this would cause just more code duplication, while the goal is still easily reachable via HTML_Table's own methods.

If you don't want to change your current code just because of this single "missing" method in the renderer, I'd recommend that you overload the renderer class, and that you add the desired method in this overloaded class yourself. (If you need more details, don't hesitate to ask.)
Back to top
View user's profile Send private message
mcmorris95125



Joined: 28 Jun 2008
Posts: 2

PostPosted: Thu Jul 03, 2008 9:45 pm    Post subject: Thanks for clarifying Reply with quote

I was afraid I was doing something wrong, or overlooking something obvious.

Having the confidence that using HTML_Table methods is really the right thing to do is all I needed!!!

I appreciate the clarification, Mark!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> Structures All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement

'Actiemonitor' online projectmanagement software