用户
 找回密码
 入住 CI 中国社区
搜索
查看: 2597|回复: 2
收起左侧

[HELP] 如何传递参数给table中的模板?

[复制链接]
发表于 2010-1-6 16:06:33 | 显示全部楼层 |阅读模式
本帖最后由 consatan 于 2010-1-6 16:09 编辑

想通过table的模板来实现双击表格行打开超链接
但是如何将数据库中的id号传递到模板中呢??
HTML复制代码
<tr ondblclick="parent.location=\'company/MyTable\'">
复制代码

链接应该是company/MyTable/id,可是这个id如何传递过来??
或者有什么别的方法可以实现我说的这功能吗?

PHP复制代码
function index() {
   $this->load->model('Company_Model','Company');
   $result = $this->Company->show_company();
   $data = array('title'  => '厂商列表',
          'message' => '厂商列表',
          'values'  => $result
          );
   $tmpl = array (
                  'table_open'         => '<table border="0" cellspacing="0">',
 
                    //'row_start'          => '<tr ondblclick="parent.location=\'company/MyTable\'" onMouseOut="this.style.background=\'\'" onMouseOver="this.style.background=\'#DCE6EE\'">',
                    'row_start'          => '<tr ondblclick="alert($result[\'id\'])" onMouseOut="this.style.background=\'\'" onMouseOver="this.style.background=\'#DCE6EE\'">',
 
                    //'row_alt_start'      => '<tr ondblclick="parent.location=\'company/MyTable\'" onMouseOut="this.style.background=\'#ECF2F6\'" onMouseOver="this.style.background=\'#DCE6EE\'" style="background=#ECF2F6" >',
                    'row_alt_start'      => '<tr ondblclick="alert($result[\'id\'])" onMouseOut="this.style.background=\'#ECF2F6\'" onMouseOver="this.style.background=\'#DCE6EE\'" style="background=#ECF2F6" >',
              );
   $this->table->set_template($tmpl);
   $this->table->set_caption('厂商列表');
   $this->table->set_heading('ID', '简称', '全称','联系人');
   $this->load->view('show_company',$data);
  }
复制代码
 楼主| 发表于 2010-1-6 16:26:58 | 显示全部楼层
搜索了下,发现有类似问题...
Hex 提议用HTML直接输出...好吧...用HTML吧...
话说真的没办法用Table类吗??是需要修改类库??
发表于 2010-1-6 17:18:41 | 显示全部楼层
table 类库不是万能的,你如果有特殊需求只能自己修改 CI 源码。

本版积分规则