consatan 发表于 2010-1-6 16:06:33

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

本帖最后由 consatan 于 2010-1-6 16:09 编辑

想通过table的模板来实现双击表格行打开超链接
但是如何将数据库中的id号传递到模板中呢??
<tr ondblclick="parent.location=\'company/MyTable\'">
链接应该是company/MyTable/id,可是这个id如何传递过来??
或者有什么别的方法可以实现我说的这功能吗?

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);
}

consatan 发表于 2010-1-6 16:26:58

{:3_60:}搜索了下,发现有类似问题...
Hex 提议用HTML直接输出...好吧...用HTML吧...
话说真的没办法用Table类吗??是需要修改类库??

Hex 发表于 2010-1-6 17:18:41

table 类库不是万能的,你如果有特殊需求只能自己修改 CI 源码。
页: [1]
查看完整版本: 如何传递参数给table中的模板?