Files
jyshd_mWtK2/public/assets/js/bootstrap-table-template.js
li 1b24994e74 feat: 后端全量更新 - 含所有本次需求
- Contract.php: 返回合约账户余额(balance_contract)
- My.php: 地址管理增加BTC/ETH
- AppContract.php: 一键平仓(closeall)
- AppProxy.php: 代理专属注册链接 + 分级权限(L1/L2)
- site.php: 手续费减半(0.018→0.009)
- agent_permission_setup.sql: 代理权限SQL
- crypto_news_crawler.py: 新闻自动采集脚本
2026-03-30 20:16:32 +08:00

75 lines
2.5 KiB
JavaScript
Executable File

/**
* 将BootstrapTable的行使用自定义的模板来渲染
*
* @author: karson
* @version: v0.0.1
*
* @update 2017-06-24 <http://github.com/karsonzhang/fastadmin>
*/
!function ($) {
'use strict';
$.extend($.fn.bootstrapTable.defaults, {
//是否启用模板渲染
templateView: false,
//数据格式化的模板ID或格式函数
templateFormatter: "itemtpl",
//添加的父类的class
templateParentClass: "row row-flex",
//向table添加的class
templateTableClass: "table-template",
});
var BootstrapTable = $.fn.bootstrapTable.Constructor,
_initContainer = BootstrapTable.prototype.initContainer,
_initBody = BootstrapTable.prototype.initBody,
_initRow = BootstrapTable.prototype.initRow;
BootstrapTable.prototype.initContainer = function () {
_initContainer.apply(this, Array.prototype.slice.apply(arguments));
var that = this;
if (!that.options.templateView) {
return;
}
that.options.cardView = true;
};
BootstrapTable.prototype.initBody = function () {
var that = this;
$.extend(that.options, {
showHeader: !that.options.templateView ? $.fn.bootstrapTable.defaults.showHeader : false,
showFooter: !that.options.templateView ? $.fn.bootstrapTable.defaults.showFooter : false,
});
$(that.$el).toggleClass(that.options.templateTableClass, that.options.templateView);
_initBody.apply(this, Array.prototype.slice.apply(arguments));
if (!that.options.templateView) {
return;
} else {
//由于Bootstrap是基于Table的,添加一个父类容器
$("> *:not(.no-records-found)", that.$body).wrapAll($("<div />").addClass(that.options.templateParentClass));
}
};
BootstrapTable.prototype.initRow = function (item, i, data, parentDom) {
var that = this;
//如果未启用则使用原生的initRow方法
if (!that.options.templateView) {
return _initRow.apply(that, Array.prototype.slice.apply(arguments));
}
var $content = '';
if (typeof that.options.templateFormatter === 'function') {
$content = that.options.templateFormatter.call(that, item, i, data);
} else {
var Template = require('template');
$content = Template(that.options.templateFormatter, {item: item, i: i, data: data});
}
return $content;
};
}(jQuery);