FastAdmin 中的 formatter flag 分析
FastAdmin 中的 formatter flag 分析
效果
首先看看效果,这里的文字和颜色可以根据数据改变。

这是系统自带的分类管理。
代码
功能在 \public\assets\js\backend\category.js。
{field: 'flag', title: __('Flag'), operate: false, formatter: Table.api.formatter.flag},
再来看看 Table.api.formatter.flag 在哪里。
\public\assets\js\require-table.js
flag: function (value, row, index) {
var that = this;
value = value === null ? '' : value.toString();
var colorArr = {index: 'success', hot: 'warning', recommend: 'danger', 'new': 'info'};
//如果字段列有定义custom
if (typeof this.custom !== 'undefined') {
colorArr = $.extend(colorArr, this.custom);
}
var field = this.field;
if (typeof this.customField !== 'undefined' && typeof row[this.customField] !== 'undefined') {
value = row[this.customField];
field = this.customField;
}
//渲染Flag
var html = [];
var arr = value.split(',');
$.each(arr, function (i, value) {
value = value === null ? '' : value.toString();
if (value == '')
return true;
var color = value && typeof colorArr[value] !== 'undefined' ? colorArr[value] : 'primary';
var display = typeof that.searchList !== 'undefined' && typeof that.searchList[value] !== 'undefined' ? that.searchList[value] : __(value.charAt(0).toUpperCase() + value.slice(1));
html.push('<a href="javascript:;" class="searchit" data-toggle="tooltip" title="' + __('Click to search %s', display) + '" data-field="' + field + '" data-value="' + value + '"><span class="label label-' + color + '">' + display + '</span></a>');
});
return html.join(' ');
},
FastAdmin 中的 formatter flag 分析的更多相关文章
- 在 FastAdmin 中启动 ThinkPHP 5 的请求缓存分析
在 FastAdmin 中启动 ThinkPHP 5 的请求缓存分析 缓存的基础配置 ThinkPHP 5 中有一个请求缓存:1 'request_cache' => true, 'reques ...
- 一张图解析FastAdmin中的表格列表的功能
大图: 1.默认生成的CRUD是没有菜单名称和描述显示的,如果需要显示则可以在后台修改,权限管理->菜单规则,给对应菜单的添加上备注信息后即可显示,支持HTML 2.TAB过滤选项卡 在一键生成 ...
- 【转】一张图解析FastAdmin中的表格列表的功能
一张图解析FastAdmin中的表格列表的功能 功能描述请根据图片上的数字索引查看对应功能说明. 1.时间筛选器如果想在搜索栏使用时间区间进行搜索,则可以在JS中修改修改字段属性,如 {field: ...
- python中的formatter的详细用法
今天抽空学习了一下python中的string service中的formatter的相关用法,主要是为了让自己的代码看起来更加和谐,因为很多java或者c语言过来的开发者都不怎么爱使用python的 ...
- FastAdmin 中 Bootstrap-Table 列宽控制
FastAdmin 中 Bootstrap-Table 列宽控制 使用 css 控制 1 使用 formatter 处理 2 http://issues.wenzhixin.net.cn/bootst ...
- 在VS 2015中边调试边分析性能
(此文章同时发表在本人微信公众号"dotNET每日精华文章",欢迎右边二维码来关注.) 对代码进行性能分析,之前往往是一种独立的Profiling过程,现在在VS 2015中可以结 ...
- u-boot中nandflash初始化流程分析(转)
u-boot中nandflash初始化流程分析(转) 原文地址http://zhuairlunjj.blog.163.com/blog/static/80050945201092011249136/ ...
- 【原】Spark中Client源码分析(二)
继续前一篇的内容.前一篇内容为: Spark中Client源码分析(一)http://www.cnblogs.com/yourarebest/p/5313006.html DriverClient中的 ...
- 【原】Spark中Master源码分析(二)
继续上一篇的内容.上一篇的内容为: Spark中Master源码分析(一) http://www.cnblogs.com/yourarebest/p/5312965.html 4.receive方法, ...
随机推荐
- python之json模块的基本使用
json模块的作用:将字符串和字典相互转换 json和eval的区别: eval函数不能识别null转换成None json可以将null转换成python可以识别的None json序列化和反序列化 ...
- java深入探究15-SpringMVC
测试代码:链接:http://pan.baidu.com/s/1c1QGYIk 密码:q924 回顾spring+struts web.xml配置;struts核心过滤器;spring监听器-> ...
- LeetCode——Construct Binary Tree from Inorder and Postorder Traversal
Question Given inorder and postorder traversal of a tree, construct the binary tree. Note: You may a ...
- 中文乱码问题(页面乱码,eclipse乱码,请求响应乱码)
1.首先在开发工具eclipse中设置工作空间和文件编码格式,详情参见 http://www.cnblogs.com/lixiang1993/p/7345161.html 2.在eclipse的安 ...
- [转]Android:改变Activity切换方式
overridePendingTransition(enterAnim, exitAnim); Intent intent =new Intent(this,item2.class); startAc ...
- java 开发面试题小整理(一)
本篇文档将持续更新,有基础滴,也有深层次的,谢谢! 1.看下面的程序是否有问题,如果有问题,请指出并说明理由. * byte b1 = 3; * byte b2 = 4; * byte b3 = b1 ...
- JavaScript文件下载 兼容所有浏览器 不可跨域
前端文件下载 兼容所有浏览器 download.js文件下载,几乎支持所有类型下载,详细内容参考官网 http://danml.com/download.html 引入文件 <script sr ...
- AppStore审核2.1被拒大礼包过审经历
本团队的iOS端迭代至今,经历过AppStore审核的数次调整,包括审核时长.严厉程度等,尝过各种花式的拒绝理由,但从没有像2018年初这次来得猛烈和漫长.从首次提交到最后过审几乎花费一个月的时间,下 ...
- R语言:导入导出数据
主要学习如何把几种常用的数据格式导入到R中进行处理,并简单介绍如何把R中的数据保存为R数据格式和csv文件. 1.保存和加载R的数据(与R.data的交互:save()函数和load()函数) a & ...
- 2017-02-20 可编辑div中如何在光标位置添加内容
之前做了一个可编辑div需要在里面插入内容,搜了好多代码,就这个能实现我的功能,记录一下,以备以后用 <!DOCTYPE HTML> <html> <head> & ...