'Status'列の値のデータベースのチェックボックスを有効または無効にする必要があります。ステータスが「クローズ」のときにチェックボックスを無効にしたい。クエリのwhere句を変更することで、クローズチケットの表示を停止できることはわかっています。しかし、私はユーザーがすべてのチケットを見ることができるようにしたい
テーブル表示
C#コード
public ActionResult GetChildTickets1(int id)
{
_db.Configuration.ProxyCreationEnabled = false;
IQueryable<VmRequest> results = _db.VmRequests.Where(i => i.ParentId == id) ;
return Json(results, JsonRequestBehavior.AllowGet);
}
JQueryコード
// Datatable value from the database
var enabletemplateListVM;
function tchildticket () {
enabletemplateListVM = {
dt: null,
init: function () {
dt = $('#childtable').DataTable({
"pageLength": 10,
"ajax": {
// Url
"url": "/Home/GetChildTickets1?id="[email protected],
"type": "POST",
"datatype": "json",
"dataSrc": function (d) {
return d
}
},
// Table Columns to display the data
"columns": [
{
"targets": [0],
"data": "Id", "autoWidth": true,
"render": function (data, type, full) {
return '<input type="checkbox" id="cticket" name="cticket" value="' + full.Id + '"/>';
},
},
{ "title": "Ticket Id", "data": "Id", "name": "Id" },
{
"title": "Logged On", "data": "CreatedOn", "name": "CreatedOn",
// Date Formating
render: function (data, type, full, meta) {
if (data !== null) {
return (moment(data).format("DD/MM/YYYY"));
} else {
return '';
}
}
},
{ "title": "Ticket Type", "data": "TypeofWork", "name": "TypeofWork" },
{ "title": "Subject", "data": "Subject", "name": "Subject" },
{ "title": "Contact", "data": "ContactId", "name": "ContactId" },
{ "title": "Status ", "data": "CurrentStatus", "name": "CurrentStatus" },
{ "title": "Team", "data": "Teamid", "name": "Teamid" },
],
});
}
}
enabletemplateListVM.init();
}
チェックボックスを含む列には、以下のコードを使用してください。
クローズされたチケットのステータス列に「クローズ」が含まれていると想定しましたが、それに応じてコードを変更してください。
{
"data": "Id",
"autoWidth": true,
"render": function (data, type, full) {
if(type === 'display'){
var attrDisabled = '';
// If ticket is closed
if(full['CurrentStatus'] === 'Closed'){
// Disable the checkbox
attrDisabled = 'disabled';
}
data = '<input type="checkbox" id="cticket" name="cticket" value="' + full.Id + '" ' + attrDisabled + '/>';
}
return data;
}
}
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加