右侧链接位置:
底部按钮位置:
在_List()方法之后,赋值$this->mytable数组,格式如下:
$this->mytable = [ 'foot_tpl' => '', // 底部按钮字符串 'link_tpl' => '', // 右侧链接字符串 'link_var' => 'html = html.replace(/\{id\}/g, row.id);html = html.replace(/\{id\}/g, row.id);', // 右侧链接的js变量替换,例如{id}表示id,可以写多组js赋值 ];
赋值完毕后,传入到模板解析:
\Phpcmf\Service::V()->assign([ 'mytable' => $this->mytable, ]);
最终效果代码:
$this->mytable = [ 'foot_tpl' => '', // 底部按钮字符串 'link_tpl' => '', // 右侧侧链接字符串 'link_var' => 'html = html.replace(/\{id\}/g, row.id);', // 侧链接的js变量替换,例如{id}表示id ]; // 侧链接,加一个a标签链接 $this->mytable['link_tpl'].= ''; \Phpcmf\Service::V()->assign([ 'mytable' => $this->mytable, ]);
底部按钮示例代码:
$this->mytable = [ 'foot_tpl' => '', // 底部按钮字符串 'link_tpl' => '', // 右侧链接字符串 'link_var' => 'html = html.replace(/\{id\}/g, row.id);', // 右侧链接的js变量替换,例如{id}表示id ]; // 底部按钮 // 加入多选框按钮 $this->mytable['foot_tpl'].= ''; // 加入删除按钮 $this->mytable['foot_tpl'].= ''; // 加入新的按钮 $this->mytable['foot_tpl'].= '
'; \Phpcmf\Service::V()->assign([ 'mytable' => $this->mytable, ]);