mirror of https://github.com/layui/layui
update
parent
25273fdcfd
commit
2642e573e8
|
@ -29,7 +29,6 @@
|
||||||
,"checkin": "106"
|
,"checkin": "106"
|
||||||
,"joinTime": "2016-10-14"
|
,"joinTime": "2016-10-14"
|
||||||
,"LAY_CHECKED": true
|
,"LAY_CHECKED": true
|
||||||
,"LAY_DISABLED": true
|
|
||||||
}, {
|
}, {
|
||||||
"id": "10003"
|
"id": "10003"
|
||||||
,"username": "苏轼"
|
,"username": "苏轼"
|
||||||
|
|
|
@ -76,8 +76,15 @@
|
||||||
|
|
||||||
<table id="test" lay-filter="test"></table>
|
<table id="test" lay-filter="test"></table>
|
||||||
|
|
||||||
<script src="../src/layui.js"></script>
|
<script src="../src/layui.js" src1="https://cdn.staticfile.org/layui/2.6.13/layui.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
(function(off){
|
||||||
|
if(!off) return;
|
||||||
|
layui.disuse('table').extend({
|
||||||
|
table: '{/}//ww:5018/layui/2.6.13/src/modules/table'
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
|
||||||
layui.use(['table', 'dropdown'], function(){
|
layui.use(['table', 'dropdown'], function(){
|
||||||
var $ = layui.$;
|
var $ = layui.$;
|
||||||
var table = layui.table;
|
var table = layui.table;
|
||||||
|
@ -113,25 +120,27 @@ layui.use(['table', 'dropdown'], function(){
|
||||||
//渲染
|
//渲染
|
||||||
window.ins1 = table.render({
|
window.ins1 = table.render({
|
||||||
elem: '#test'
|
elem: '#test'
|
||||||
,height: 500
|
,height: 520
|
||||||
//,width: 600
|
//,width: 600
|
||||||
,title: '用户数据表'
|
,title: '用户数据表'
|
||||||
,url: 'json/table/demo1.json'
|
,url: 'json/table/demo1.json'
|
||||||
//,method: 'post'
|
//,method: 'post'
|
||||||
|
|
||||||
,pagebar: '#pagebarDemo' // 分页栏模板
|
|
||||||
//,lineStyle: 'height: 95px;' // 行样式
|
//,lineStyle: 'height: 95px;' // 行样式
|
||||||
,css: [ // 自定义样式
|
,css: [ // 自定义样式
|
||||||
'.layui-table-page{text-align: right;}'
|
'.layui-table-page{text-align: right;}'
|
||||||
,'.layui-table-pagebar{float: left;}'
|
,'.layui-table-pagebar{float: left;}'
|
||||||
].join('')
|
].join('')
|
||||||
|
//,className: '.demo-table-view'
|
||||||
|
|
||||||
//,size: 'sm'
|
//,size: 'sm'
|
||||||
//,skin: 'line'
|
//,skin: 'line'
|
||||||
//,autoSort: false //是否自动排序。如果否,则由服务端排序
|
|
||||||
//,loading: false
|
//,loading: false
|
||||||
|
|
||||||
,totalRow: true
|
,totalRow: true
|
||||||
,page: {
|
,pagebar: '#pagebarDemo' // 分页栏模板
|
||||||
|
,page: !1 ? false : {
|
||||||
//curr: layui.data('tableCache').curr || 1 // 读取记录中的页码,赋值给起始页
|
//curr: layui.data('tableCache').curr || 1 // 读取记录中的页码,赋值给起始页
|
||||||
}
|
}
|
||||||
,limit: 30
|
,limit: 30
|
||||||
|
@ -144,6 +153,7 @@ layui.use(['table', 'dropdown'], function(){
|
||||||
//,escape: false
|
//,escape: false
|
||||||
,cols: !1 ? test_cols : [[
|
,cols: !1 ? test_cols : [[
|
||||||
{type: 'checkbox', fixed: 'left'}
|
{type: 'checkbox', fixed: 'left'}
|
||||||
|
//,{type: 'numbers', fixed: 'left'}
|
||||||
,{field:'id', title:'ID', width:80, fixed: 'left', unresize: true, sort: true, totalRowText: '合计:'}
|
,{field:'id', title:'ID', width:80, fixed: 'left', unresize: true, sort: true, totalRowText: '合计:'}
|
||||||
,{field:'username', title:'用户名', width:120, edit: 'text', templet: '#usernameTpl'}
|
,{field:'username', title:'用户名', width:120, edit: 'text', templet: '#usernameTpl'}
|
||||||
,{field:'email', title:'邮箱 <i class="layui-icon layui-icon-email"></i>', hide: 0, width:150, edit: 'text', templet: function(d){
|
,{field:'email', title:'邮箱 <i class="layui-icon layui-icon-email"></i>', hide: 0, width:150, edit: 'text', templet: function(d){
|
||||||
|
@ -163,7 +173,7 @@ layui.use(['table', 'dropdown'], function(){
|
||||||
,{fixed: 'right', title:'操作', toolbar: '#barDemo', width: 180}
|
,{fixed: 'right', title:'操作', toolbar: '#barDemo', width: 180}
|
||||||
]]
|
]]
|
||||||
|
|
||||||
//,autoSort: false // 禁用前端自动排序
|
//,autoSort: false // 禁用前端自动排序,由服务的完成排序
|
||||||
,initSort11111: { // 初始排序状态
|
,initSort11111: { // 初始排序状态
|
||||||
field: 'experience' //排序字段,对应 cols 设定的各字段名
|
field: 'experience' //排序字段,对应 cols 设定的各字段名
|
||||||
,type: 'desc' //排序方式 asc: 升序、desc: 降序、null: 默认排序
|
,type: 'desc' //排序方式 asc: 升序、desc: 降序、null: 默认排序
|
||||||
|
|
|
@ -238,7 +238,7 @@
|
||||||
apps = that.isArray(apps) ? apps : [apps];
|
apps = that.isArray(apps) ? apps : [apps];
|
||||||
that.each(apps, function (index, item) {
|
that.each(apps, function (index, item) {
|
||||||
if (!config.status[item]) {
|
if (!config.status[item]) {
|
||||||
return error('module ' + item + ' is not exist');
|
//return error('module ' + item + ' is not exist');
|
||||||
}
|
}
|
||||||
delete that[item];
|
delete that[item];
|
||||||
delete modules[item];
|
delete modules[item];
|
||||||
|
@ -246,6 +246,7 @@
|
||||||
delete config.status[item];
|
delete config.status[item];
|
||||||
delete config.modules[item];
|
delete config.modules[item];
|
||||||
});
|
});
|
||||||
|
return that;
|
||||||
};
|
};
|
||||||
|
|
||||||
//获取节点的 style 属性值
|
//获取节点的 style 属性值
|
||||||
|
|
|
@ -26,6 +26,9 @@ layui.define(['util'], function(exports){
|
||||||
layui.each(elems.reverse(), function(index, item){
|
layui.each(elems.reverse(), function(index, item){
|
||||||
var othis = $(item);
|
var othis = $(item);
|
||||||
var html = trim(othis.html());
|
var html = trim(othis.html());
|
||||||
|
var about = othis.attr('lay-about') || options.about || (
|
||||||
|
othis.attr('lay-lang') || options.lang
|
||||||
|
) || '';
|
||||||
|
|
||||||
// 转义 HTML 标签
|
// 转义 HTML 标签
|
||||||
if(othis.attr('lay-encode') || options.encode){
|
if(othis.attr('lay-encode') || options.encode){
|
||||||
|
@ -35,7 +38,7 @@ layui.define(['util'], function(exports){
|
||||||
othis.html('<ol class="layui-code-ol"><li>' + html.replace(/[\r\t\n]+/g, '</li><li>') + '</li></ol>')
|
othis.html('<ol class="layui-code-ol"><li>' + html.replace(/[\r\t\n]+/g, '</li><li>') + '</li></ol>')
|
||||||
|
|
||||||
if(!othis.find('>.layui-code-h3')[0]){
|
if(!othis.find('>.layui-code-h3')[0]){
|
||||||
othis.prepend('<h3 class="layui-code-h3">'+ (othis.attr('lay-title')||options.title||'</>') + '<a href="javascript:;">'+ (othis.attr('lay-lang')||options.lang||'') +'</a>' + '</h3>');
|
othis.prepend('<h3 class="layui-code-h3">'+ (othis.attr('lay-title')||options.title||'</>') + '<a href="javascript:;">'+ about +'</a>' + '</h3>');
|
||||||
}
|
}
|
||||||
|
|
||||||
var ol = othis.find('>.layui-code-ol');
|
var ol = othis.find('>.layui-code-ol');
|
||||||
|
|
|
@ -15,13 +15,13 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||||
var hint = layui.hint();
|
var hint = layui.hint();
|
||||||
var device = layui.device();
|
var device = layui.device();
|
||||||
|
|
||||||
//外部接口
|
// api
|
||||||
var table = {
|
var table = {
|
||||||
config: {
|
config: { // 全局配置项
|
||||||
checkName: 'LAY_CHECKED' // 是否选中状态的字段名
|
checkName: 'LAY_CHECKED' // 是否选中状态的字段名
|
||||||
,indexName: 'LAY_TABLE_INDEX' // 初始下标索引名,用于恢复排序
|
,indexName: 'LAY_TABLE_INDEX' // 初始下标索引名,用于恢复排序
|
||||||
,disabledName: 'LAY_DISABLED'
|
,disabledName: 'LAY_DISABLED'
|
||||||
} //全局配置项
|
}
|
||||||
,cache: {} // 数据缓存
|
,cache: {} // 数据缓存
|
||||||
,index: layui.table ? (layui.table.index + 10000) : 0
|
,index: layui.table ? (layui.table.index + 10000) : 0
|
||||||
|
|
||||||
|
@ -98,10 +98,32 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||||
return obj.text ? $('<div>'+ content +'</div>').text() : content;
|
return obj.text ? $('<div>'+ content +'</div>').text() : content;
|
||||||
}
|
}
|
||||||
|
|
||||||
//字符常量
|
// 字符
|
||||||
,MOD_NAME = 'table', ELEM = '.layui-table', THIS = 'layui-this', SHOW = 'layui-show', HIDE = 'layui-hide', HIDE_V = 'layui-hide-v', DISABLED = 'layui-disabled', NONE = 'layui-none'
|
,MOD_NAME = 'table'
|
||||||
|
,ELEM = '.layui-table'
|
||||||
|
,THIS = 'layui-this'
|
||||||
|
,SHOW = 'layui-show'
|
||||||
|
,HIDE = 'layui-hide'
|
||||||
|
,HIDE_V = 'layui-hide-v'
|
||||||
|
,DISABLED = 'layui-disabled'
|
||||||
|
,NONE = 'layui-none'
|
||||||
|
|
||||||
,ELEM_VIEW = 'layui-table-view', ELEM_TOOL = '.layui-table-tool', ELEM_BOX = '.layui-table-box', ELEM_INIT = '.layui-table-init', ELEM_HEADER = '.layui-table-header', ELEM_BODY = '.layui-table-body', ELEM_MAIN = '.layui-table-main', ELEM_FIXED = '.layui-table-fixed', ELEM_FIXL = '.layui-table-fixed-l', ELEM_FIXR = '.layui-table-fixed-r', ELEM_TOTAL = '.layui-table-total', ELEM_PAGE = '.layui-table-page', ELEM_PAGE_VIEW = '.layui-table-pageview', ELEM_SORT = '.layui-table-sort', ELEM_EDIT = 'layui-table-edit', ELEM_HOVER = 'layui-table-hover'
|
,ELEM_VIEW = 'layui-table-view'
|
||||||
|
,ELEM_TOOL = '.layui-table-tool'
|
||||||
|
,ELEM_BOX = '.layui-table-box'
|
||||||
|
,ELEM_INIT = '.layui-table-init'
|
||||||
|
,ELEM_HEADER = '.layui-table-header'
|
||||||
|
,ELEM_BODY = '.layui-table-body'
|
||||||
|
,ELEM_MAIN = '.layui-table-main'
|
||||||
|
,ELEM_FIXED = '.layui-table-fixed'
|
||||||
|
,ELEM_FIXL = '.layui-table-fixed-l'
|
||||||
|
,ELEM_FIXR = '.layui-table-fixed-r'
|
||||||
|
,ELEM_TOTAL = '.layui-table-total'
|
||||||
|
,ELEM_PAGE = '.layui-table-page'
|
||||||
|
,ELEM_PAGE_VIEW = '.layui-table-pageview'
|
||||||
|
,ELEM_SORT = '.layui-table-sort'
|
||||||
|
,ELEM_EDIT = 'layui-table-edit'
|
||||||
|
,ELEM_HOVER = 'layui-table-hover'
|
||||||
|
|
||||||
// thead 区域模板
|
// thead 区域模板
|
||||||
,TPL_HEADER = function(options){
|
,TPL_HEADER = function(options){
|
||||||
|
@ -326,10 +348,15 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||||
,hasRender = othis.next('.' + ELEM_VIEW)
|
,hasRender = othis.next('.' + ELEM_VIEW)
|
||||||
|
|
||||||
//主容器
|
//主容器
|
||||||
,reElem = that.elem = $('<div class="layui-form layui-border-box"></div>');
|
,reElem = that.elem = $('<div></div>');
|
||||||
|
|
||||||
reElem.addClass(function(){
|
reElem.addClass(function(){
|
||||||
var arr = [ELEM_VIEW, ELEM_VIEW +'-'+ that.index];
|
var arr = [
|
||||||
|
ELEM_VIEW,
|
||||||
|
ELEM_VIEW +'-'+ that.index,
|
||||||
|
'layui-form',
|
||||||
|
'layui-border-box'
|
||||||
|
];
|
||||||
if(options.className) arr.push(options.className);
|
if(options.className) arr.push(options.className);
|
||||||
return arr.join(' ');
|
return arr.join(' ');
|
||||||
}()).attr({
|
}()).attr({
|
||||||
|
@ -603,13 +630,13 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||||
|
|
||||||
//动态分配列宽
|
//动态分配列宽
|
||||||
Class.prototype.setColsWidth = function(){
|
Class.prototype.setColsWidth = function(){
|
||||||
var that = this
|
var that = this;
|
||||||
,options = that.config
|
var options = that.config;
|
||||||
,colNums = 0 //列个数
|
var colNums = 0; // 列个数
|
||||||
,autoColNums = 0 //自动列宽的列个数
|
var autoColNums = 0; // 自动列宽的列个数
|
||||||
,autoWidth = 0 //自动列分配的宽度
|
var autoWidth = 0; // 自动列分配的宽度
|
||||||
,countWidth = 0 //所有列总宽度和
|
var countWidth = 0; // 所有列总宽度和
|
||||||
,cntrWidth = that.setInit('width');
|
var cntrWidth = that.setInit('width');
|
||||||
|
|
||||||
// 统计列个数
|
// 统计列个数
|
||||||
that.eachCols(function(i, item){
|
that.eachCols(function(i, item){
|
||||||
|
@ -672,7 +699,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||||
var minWidth = item3.minWidth || options.cellMinWidth;
|
var minWidth = item3.minWidth || options.cellMinWidth;
|
||||||
if(item3.colGroup || item3.hide) return;
|
if(item3.colGroup || item3.hide) return;
|
||||||
|
|
||||||
//给位分配宽的列平均分配宽
|
// 给未分配宽的列平均分配宽
|
||||||
if(item3.width === 0){
|
if(item3.width === 0){
|
||||||
that.getCssRule(options.index +'-'+ item3.key, function(item){
|
that.getCssRule(options.index +'-'+ item3.key, function(item){
|
||||||
item.style.width = Math.floor(autoWidth >= minWidth ? autoWidth : minWidth) + 'px';
|
item.style.width = Math.floor(autoWidth >= minWidth ? autoWidth : minWidth) + 'px';
|
||||||
|
@ -1008,6 +1035,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||||
|
|
||||||
// 因为 page 参数有可能发生变化 先重新铺满
|
// 因为 page 参数有可能发生变化 先重新铺满
|
||||||
that.fullSize();
|
that.fullSize();
|
||||||
|
|
||||||
// 滚动条补丁
|
// 滚动条补丁
|
||||||
that.haveInit ? that.scrollPatch() : setTimeout(function(){
|
that.haveInit ? that.scrollPatch() : setTimeout(function(){
|
||||||
that.scrollPatch();
|
that.scrollPatch();
|
||||||
|
|
Loading…
Reference in New Issue