How to reach data column value in JSON format . I used row[requestStatus.name]

How to reach data column value in JSON format . I used row[requestStatus.name]

MesutDtkMesutDtk Posts: 1Questions: 0Answers: 0
edited August 5 in Free community support
var dataTable;
$(document).ready(function () {
    dataTable = $('#DT_RequestsAdmin').DataTable({
        "ajax": {
            "url": "/api/AdminRequest",
            "type": "GET",
            "datatype": "json"
        },
        autoWidth: false,
        "columns": [
            { "data": "requestID", "width": "1%" },
            { "data": "summary", "width": "10%" },
            { "data": "description", "width": "15%" },
            { "data": "requesterUser.fullName", "width": "4%" },
            { "data": "engineerUser.fullName", "width": "4%" },
            { "data": "requestStatus.name", "width": "8%" },
            { "data": "department.name", "width": "7%" },
            { "data": "reason.name", "width": "10%" },
 
            {

                "data": "requestID",
                "render": function (data, row) {
                    if (row['requestStatus.name'] == 'On Hold') {
                        return `<div class="w-75 btn-group" >
                            <a href="/Admin/Requests/upsert?id=${data}"  class="btn btn-success text-white mx-2">
                            <i class="bi bi-pencil-square"></i></a>
                              
                            </div>`
                    }
                    if (row['requestStatus.name'] == 'Canceled') {
                        return `<div class="w-75 btn-group" >
                            <a href="/Admin/Requests/upsert?id=${data}"  class="btn btn-success text-white mx-2">
                            <i class="bi bi-pencil-square"></i></a>
                            <a onClick=Delete('/api/AdminRequest/'+${data})  class="btn btn-danger text-white mx-2">
                             <i class="bi bi-trash-fill" ></i></a>
                            </div>`
                        }
                },

                "width": "1%"
            }
        ],
       
    });
});

Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide

Replies

Sign In or Register to comment.