【发布时间】:2020-11-17 10:24:15
【问题描述】:
将过滤器添加到表列(状态)的最简单方法是什么?我发现了不同的东西,但它们都建议使用搜索框之类的东西,但我不希望那样。我尝试了另一件事,但没有奏效。下面是我的代码,没有任何过滤器。非常感谢您的帮助。
控制器
public ActionResult ViewAllTasks()
{
HelpDeskDBHandle dbhandle = new HelpDeskDBHandle();
return View(dbhandle.GetITTasksList());
}
//LIST IT TASKS
public JsonResult ListITTasks()
{
HelpDeskDBHandle hdDB = new HelpDeskDBHandle();
return Json(hdDB.GetITTasksList(), JsonRequestBehavior.AllowGet);
}
查看
@*IT TASKS PAGE----------------------------------------------------------------------------------------*@
@model IEnumerable<HelpDeskSupport.Models.ITTasksModel>
@{
Layout = null;
}
<head>
<meta name="viewport" content="width=device-width" />
<title>ViewAllTasks</title>
<script src="~/Scripts/ITTasksJS.js"></script>
</head>
<div class="container">
<h2>IT Tasks</h2>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal"
onclick="clearTextBox();">Add New Task</button><br /><br />
<table class="display table table-striped table-bordered" id="knowledgeTable">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.ITNumber)
</th>
<th>
@Html.DisplayNameFor(model => model.ITDescription)
</th>
<th>
@Html.DisplayNameFor(model => model.ITEnterDate)
</th>
<th>
@Html.DisplayNameFor(model => model.ITAssignedTo)
</th>
<th>
@Html.DisplayNameFor(model => model.ITEstimatedCompletion)
</th>
<th>
@Html.DisplayNameFor(model => model.ITPriority)
</th>
<th>
@Html.DisplayNameFor(model => model.ITFrom)
</th>
<th>
@Html.DisplayNameFor(model => model.ITStatus)
</th>
</tr>
</thead>
<tbody class="tbody">
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.ITNumber)
</td>
<td>
@Html.DisplayFor(modelItem => item.ITDescription)
</td>
<td>
@Html.DisplayFor(modelItem => item.ITEnterDate)
</td>
<td>
@Html.DisplayFor(modelItem => item.ITAssignedTo)
</td>
<td>
@Html.DisplayFor(modelItem => item.ITEstimatedCompletion)
</td>
<td>
@Html.DisplayFor(modelItem => item.ITPriority)
</td>
<td>
@Html.DisplayFor(modelItem => item.ITFrom)
</td>
<td>
@Html.DisplayFor(modelItem => item.ITStatus)
</td>
</tr>
}
</tbody>
</table>
</div>
JAVASCRIPT
//Load Data in Table when documents is ready
$(document).ready(function () {
loadData();
});
//Load Data function
function loadData() {
$.ajax({
url: "/Tickets/ListITTasks",
type: "GET",
contentType: "application/json;charset=utf-8",
dataType: "json",
success: function (result) {
var html = '';
$.each(result, function (key, item) {
html += '<tr>';
html += '<td>' + item.ITNumber + '</td>';
html += '<td>' + item.ITDescription + '</td>';
html += '<td>' + item.ITEnterDate + '</td>';
html += '<td>' + item.ITAssignedTo + '</td>';
html += '<td>' + item.ITEstimatedCompletion + '</td>';
html += '<td>' + item.ITPriority + '</td>';
html += '<td>' + item.ITFrom + '</td>';
html += '<td>' + item.ITStatus + '</td>';
html += '<td><a href="#" onclick="return getbyTicketNumber(' + item.ITNumber +
')">Edit</a> | <a href="#" onclick="DeleteItTask(' + item.ITNumber + ')">Delete</a></td>';
html += '</tr>';
});
$('.tbody').html(html);
alert("Successful Loaddata ITTASK");
},
error: function (errormessage) {
alert(errormessage.responseText);
}
});
}
再次感谢!!!
【问题讨论】:
-
ITStatus的可能值是多少? -
Closed 或 open 将是 status 的值。
标签: javascript c# html jquery model-view-controller