**
## 1.界面显示(按钮+表格)
**
<div class="layui-btn-container">
<button class="layui-btn layui-btn-sm" id="btnSearch" style="width: 100px">查询</button>
</div>
<br />
<table class="layui-hide" id="checkList" lay-filter="test"></table>
**
## 2.前端呈现方法
**
<script type="text/javascript">
layui.use(['layer', 'form', 'table', 'upload', 'element'], function () {
var layer = layui.layer,
upload = layui.upload,
element = layui.element,
form = layui.form;
$ = layui.jquery;
var table = layui.table;
$("#btnSearch").on("click", function () {
GetListData(table);
});
});
function GetListData(table) {
$.ajax({
url: '/XXXX/GetDataNow/',
type: 'get',
dataType: 'json',
success: function (data) {
ShowTableList(table, data);
},
error: function (err) {
layer.alert(err);
}
});
}
function ShowTableList(table, dt) {
table.render({
elem: '#checkList'
, height: "full-185"
, cols: [[
{ type: 'checkbox', fixed: 'left' }
, { field: 'aaa', title: '工厂', sort: true, width: 100, fixed: 'left', align: 'center' }
, { field: 'bbb', title: '托盘号', sort: true, width: 200, fixed: 'left', align: 'center' }
, { field: 'ccc', title: '批次号', width: 220, align: 'center' }
, { field: 'ddd', title: '数量', width: 120, align: 'center' }
, { field: 'eee', title: '计量单位', width: 250, align: 'center' }
, { field: 'fff', title: '状态', width: 100, align: 'center' }
]]
, data: dt
, page: true
, limit: 10
});
}
</script>
**
## 3.后台数据查询(MVC)
**
#region [查询数据]
[HttpGet]
public string GetDataNow()
{
List<数据实体类> list = bll.GetDataNow();
return JsonConvert.SerializeObject(list);
}
#endregion