前言
博主由于工作需要自学了ASP.NET和C#,前端用的是Layui,写篇博客记录一下实现过程,就当是公开的有道云笔记哈哈,如果有更简便的方法欢迎留言评论~
前端Layui表格
layui.use('table', function () {
var table = layui.table;
var form = layui.form;
table.render({
elem: '#test'
, url: 'Edittable.ashx'
, where: {
id: 1
, Query: $("#Query").val()
, Sub_query: $("#Sub_query").val()
, Created_Alias: $("#Created_Alias").val()
}
, method: 'get'
, cols: [[
{
type: 'checkbox', fixed: 'left' }
, {
field: 'ID', width: 60, title: 'ID', sort: true, fixed: 'left' }
, {
field: 'Warning_Time', width: 195, title: 'Warning Time', sort: true,
templet: function (d) {
if (d.Status != "Solved") {
var mydate = new Date(d.Created_Date);
var tp = (parseInt(new Date() - mydate) / 1000 / 60 / 60);
if (tp <= 4) {
return '<span><object data="image/bulb_green.svg" height="30px" />' + d.Warning_Time + '</span>'
} else if (4 < tp && tp <= 6) {
return '<span><object data="image/bulb_blue.svg" height="30px" />' + d.Warning_Time + '</span>'
} else if (6 < tp && tp <= 8) {
return '<span><object data="image/bulb_orange.svg" height="30px" />' + d.Warning_Time + '</span>'
} else if (tp > 8) {
return '<span><object data="image/bulb_red.svg" height="30px" />' + d.Warning_Time + '</span>'
}
} else {
return '<span> ' + d.Warning_Time + '</span>'
}
}
}
, {
field: 'Status', width: 150, title: 'Status',
templet: '#StatusTpl'
}
, {
field: 'SIT_PIC', width: 150, title: 'SIT PIC' }
, {
field: 'Query', templet: '#titleTpl', width: 150, title: 'Query' }
, {
field: 'Sub_query', width: 150, title: 'Sub query' }
, {
field: 'Created_Alias', width: 120, title: 'Created Alias' }
, {
field: 'Team', width: 180, title: 'Team'