cakephp tableHeaders和width [英] cakephp tableHeaders and width
问题描述
为什么我得到th单元格名称Array?
如何设置表的宽度?
why i get th cell name "Array" ? How set table th width?
$th = array( array(array(null),
array('width'=>'80')) );
echo $this->Html->tableHeaders($th);
推荐答案
方法正确。
tableHeaders()的正确用法是tableHeaders($ tableHeaders,$ trOptions,$ thOptions);
The proper usage for tableHeaders() is tableHeaders($tableHeaders, $trOptions, $thOptions);
$ trOptions和$ thOptions应该是您为HTML元素设置选项的数组。
The $trOptions and $thOptions should be arrays where you set the options for the HTML elements.
因此,要设置您尝试做的宽度你必须这样做:
So to set the th width as you're trying to do above you'd have to do something like this:
$th = array('Col1', 'Col2', 'Col3');
$trOptions = array();
$thOptions = array('width' => 80);
echo $this->Html->tableHeaders($th, $trOptions, $thOptions);
th选项数组必须是第三个参数,所以你必须包括$ trOptions作为第二个如果它只是一个空数组。
The th options array has to be the third argument so you have to include $trOptions as the second even if it's just an empty array.
所有这些信息实际上在CakePHP文档和API中解释得很好,所以我建议你检查一下,如果你
All this info is actually explained quite well in the CakePHP documentation and API, so I'd encourage you to check there as well if you haven't already.
这里是$ Html-> tableHeaders在文档中的信息:
http://book.cakephp.org/view/1446/tableHeaders
Here's info on $Html->tableHeaders in the documentation: http://book.cakephp.org/view/1446/tableHeaders
这是条目对于CakePHP API中的$ Html-> tableHeaders:
http:// api.cakephp.org/class/html-helper#method-HtmlHelpertableHeaders
Here's the entry for $Html->tableHeaders in the CakePHP API: http://api.cakephp.org/class/html-helper#method-HtmlHelpertableHeaders
这篇关于cakephp tableHeaders和width的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!