示例代碼:
layui.use([ 'form', 'table'], function() {
var table = layui.table, form = layui.form, $ = layui.$;
var index = layer.load(1);
table.render({
elem: '#tableData',
url: basePath + '/mainTab/selectDataByType?breakRawType=' + $("#breakRawType").val() + "&ah=" + $("#ah").val() + "&wfzt=" + $("#wfzt").val(),
request: {
pageName: 'page', //頁(yè)碼的參數(shù)名稱岩瘦,默認(rèn):page
limitName: 'rows' //每頁(yè)數(shù)據(jù)量的參數(shù)名,默認(rèn):limit
},
// cellMinWidth: 100,
cols : [[ // 表頭
{
field : 'ah',
title : '案號(hào)',
align : 'center',
width : '23%',
event : 'seeDetail',
style: 'cursor: pointer;color:#0000CC;',
sort : true
},{
field : 'wfzt',
title : '違法主體',
width : '20%',
align : "center"
// sort : true
}]],
skin: 'row', //表格風(fēng)格
even: true, //隔行背景
page :true,
limits: [30, 50, 100], //顯示
limit: 30, //每頁(yè)默認(rèn)顯示的數(shù)量
id:'tableReload',
done : function(res, curr, count){
//太長(zhǎng)title 提示
$("tr td").hover(function() {
$(this).attr("title", $(this).text());
}, function() {
$(this).removeAttr("title");
});
layer.close(index); //返回?cái)?shù)據(jù)關(guān)閉loading
}
});
});
主要添加:
var index = layer.load(1);
,done:function (res) { //返回?cái)?shù)據(jù)執(zhí)行回調(diào)函數(shù)
layer.close(index); //返回?cái)?shù)據(jù)關(guān)閉loading
}
??附:
通過(guò)方法添加的加載進(jìn)度條展示伶棒,參考代碼如下:
function showLoad() {
return layer.msg('拼命執(zhí)行中...', {icon: 16,shade: [0.5, '#f5f5f5'],scrollbar: false,offset: 'auto', time:100000});
}
function closeLoad(index) {
layer.close(index);
}