根据条件判断添加按钮,增加visible
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate, buttons: [
{
'name': 'form_field',
'title': function (row) {
return '活动表单字段[' + row.title + ']';
},
'icon': 'fa fa-list',
'text': '表单字段',
'classname': 'btn btn-xs btn-success btn-dialog',
'url': 'activity/fields/index/source/{table}/source_id/{ids}',
'extend': 'data-area=\'["95%","95%"]\'',
'visible':function(row){
if(row.is_form == 1){
return true;
}else{
return false;
}
},
}
]}
根据条件值判断是否显示 删除/编辑
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: function(value, row, index) {
var that = $.extend({}, this);
var table = $(that.table).clone(true);
if (row.name === 'title') {
$(table).data("operate-del", null);
}
that.table = table;
return Table.api.formatter.operate.call(that, value, row, index);
}
}
关联查询必须加一句代码,否则会报字段冲突
$this->relationSearch = true;
thinkphp关联查询指定查询字段
$list = $this->model->with(['user'=>function($query){
$query->field('username,nickname');
}])->where($where)
->order($sort, $order)
->paginate($limit);
thinkphp富文本字符串切割
if (!function_exists('msubstr')) {
function msubstr($str, $length, $start = 0, $charset = "utf-8", $suffix = true)
{
if (function_exists("mb_substr")) {
$slice = mb_substr($str, $start, $length, $charset);
if ($suffix) {
if (mb_strlen($str, 'utf-8') > $length) {
return $slice . "...";
} else {
return $slice;
}
} else {
return $slice;
}
} elseif (function_exists('iconv_substr')) {
if ($suffix) {
return iconv_substr($str, $start, $length, $charset) . "...";
} else {
return iconv_substr($str, $start, $length, $charset);
}
}
$re['utf-8'] = "/[x01-x7f]|[xc2-xdf][x80-xbf]|[xe0-xef][x80-xbf]{2}|[xf0-xff][x80-xbf]{3}/";
$re['gb2312'] = "/[x01-x7f]|[xb0-xf7][xa0-xfe]/";
$re['gbk'] = "/[x01-x7f]|[x81-xfe][x40-xfe]/";
$re['big5'] = "/[x01-x7f]|[x81-xfe]([x40-x7e]|xa1-xfe])/";
preg_match_all($re[$charset], $str, $match);
$slice = join("", array_slice($match[0], $start, $length));
if ($suffix) {
if (strlen($slice) > $length) {
return $slice . "…";
} else {
return $slice;
}
}
return $slice;
}
}
{$about.content|raw|htmlspecialchars_decode|strip_tags|msubstr=70}