1.引入外部js并调用
require(['spectrum'], function (spectrum) {
var col = $("#c-mcolor").val();
$("#c-mcolor").spectrum({
color: col,
preferredFormat: "hex",
showInput: true,
});
var gcol = $("#c-mbgcolor").val();
$("#c-mbgcolor").spectrum({
color: gcol,
preferredFormat: "hex",
showInput: true,
});
});
2.隐藏某字段的显示和隐藏通用搜索
//visible隐藏字段,operate隐藏通用搜索
{
field: 'id', title: __('Id'),visible: false,operate: false},
3.通用搜索改为select搜索
js代码
//data是添加属性
{
field: 'reptype', title: __('Reptype'),searchList: $.getJSON("ajax/reptype"),data:' id = "mm_city" '},
//或者直接写
{
field: 'status', title: __('status'), searchList: {
"0":__('待审核'),"1,2,3":__('已审')}},
ajax控制器中代码
public function reptype(){
$areaList = Db::name('report_type')->field('id,name')->select();
return json($areaList);
}
4.给某字段添加判断效果
{
field: 'createtime', title: __('Createtime'), formatter:function(value,row,index){
if( 0 < value && value <= 3){
return '<b style = "color:red">' + value + '天</b>';
}else{
return value + "天" ;
}
}},
5.在操作中添加按钮
{
field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, buttons: [{
name: 'det