English 中文(简体)
内部自定义布局的编码Igniter HTML 表格生成器
原标题:CodeIgniter HTML table generator with custom layout inside

CI table- gt; generate ($data1, $data2, $data3, 以 < 坚固 > 简单表格 的形式输出我的数据,例如:

<table>
    <tr>
        <td>data1</td>
        <td>data2</td>
        <td>data3</td>
    </tr>
</table>

如果我需要每个单元格内有多个 $vars 的 < 坚固 > 复合单元格布局 :

$data1 = array( one ,  two ,  three ); 

我想要这样的东西:

<table>
    <tr>
        <td>
            <div class="caption">$data1[0]</div>
            <span class="span1">$data1[1] and here goes <strong>$data1[2]</strong></span>
        </td>
        <td>...</td>
        <td>...</td>
    </tr>
</table>

我该如何编码那块?

现在我只是在模型中生成 td 的内容, 然后调用 generate () < (/code) > 。 但这意味着我的单元格 HTML 在模型中, 但我想将其保留在视图中 。

最佳回答

我想说的是,你应该通过生成 td 结构的数据。 捕捉视图的输出, 并将其传递到桌面生成器。 这保持了您的结构, 尽管它不同 。

问题回答

Hailwood s answer isn t the best way to do it. the html table class has a data element on the add_row method. so the code would be:

$row = array();
$row[] = array( data  => "<div class= caption >{$data1[0]}</div><span class= span1 >{$data1[1]} and here goes <strong>{$data1[2]}</strong></span>");
$row[] = $col2;
$row[] = $col3;

$this->table->add_row($row)
echo $this->table->generate();

将表格中有一个名为标题的课目放在桌边,因为表格中有一个标题标签,所以在表格中有一个类目标题会令语义混乱。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!