后台接口
[HttpPost]
public IHttpActionResult GetTest(dynamic input)
{
string sqlwhere="1=1";
int recordCount = 0;
int page = input.page ?? 1;
int limit = input.limit ?? 10;
List<T_Test> list = B_Base_Security.QueryDataToList(new T_Test(), page, limit, out recordCount, sqlwhere, "CreateTime desc");
List<dynamic> resobj = new List<dynamic>();
if (list != null && list.Count > 0)
{
foreach (var item in list)
{
resobj.Add(new
{
Title = item.Title.Value,
Lsh = item.Lsh.Value,
LAY_DISABLED=true,//是否禁用
LAY_CHECKED = true //是否选中 true选中,false不选择
});
}
}
return Json<dynamic>(new { code = "0", data = resobj, count = recordCount, msg = "成功", });
}
前台
<table class="layui-table" style="padding: 20px;" id="Table" lay-filter="Table"></table>
table.render({
elem: '#Table',
url: $.UserInfo("apiurl") + '/NewApple/GetTest',
cellMinWidth: 100,
page: true,
method: "post",
contentType: "application/json",
limits: [10, 15, 20, 25],
limit: 10,
id: "Table",
where: { Lsh: Lsh },
cols: [[
{ fixed: "Lsh", type: "checkbox", width: '5%', align: "center" },
{ field: 'Title', title: '案例标题', width: '75%', fixed: 'left', align: "center" },
{
title: '操作', fixed: "Lsh", type: "text", width: '20%', align: "center", fixed: 'left', templet: function (d) {
var Html = '<a style="color:#0070cc" href="###" lay-event="qua_sel"> 查 看 </a> ';
return Html;
}
},
]]
});
效果