Is it possible to achieve a nested object structure of JSON response using Editor?

Is it possible to achieve a nested object structure of JSON response using Editor?

bobhassansterbobhassanster Posts: 16Questions: 5Answers: 1

Link to test case: https://demos.themeselection.com/sneat-bootstrap-html-admin-template/html/vertical-menu-template-dark/app-access-permission.html
Description of problem: I am trying to achieve this structure of JSON response using editor from a table (role, permiss)?
(3,Admin)
(3,Manager)

{
"id": 3,
"name": "Add & Remove Users",
"assigned_to": [
"Admin",
"Manager"
]
}

Thanks.

Answers

  • allanallan Posts: 63,643Questions: 1Answers: 10,492 Site admin

    Do you mean to allow Editor to handle this sort of response from the server (rather than the data array), or do you mean you want to submit data as JSON rather than HTTP parameters?

    Allan

  • bobhassansterbobhassanster Posts: 16Questions: 5Answers: 1

    Yes using Editor to retrieve the response from the server, the Link test is using just a json file but me i want to have the Data from the server using Editor. Thank you.

  • bobhassansterbobhassanster Posts: 16Questions: 5Answers: 1

    The reason why is to apply this render to the second column:

    {
    // User Role
    targets: 2,
    orderable: false,
    render: function (data, type, full, meta) {
    var $assignedTo = full['assigned_to'],
    $output = '';
    var roleBadgeObj = {
    Admin: '<a href="' + userList + '"><span class="badge bg-label-primary m-1">Administrator</span></a>',
    Manager: '<a href="' + userList + '"><span class="badge bg-label-warning m-1">Manager</span></a>',
    Users: '<a href="' + userList + '"><span class="badge bg-label-success m-1">Users</span></a>',
    Support: '<a href="' + userList + '"><span class="badge bg-label-info m-1">Support</span></a>',
    Restricted:
    '<a href="' + userList + '"><span class="badge bg-label-danger m-1">Restricted User</span></a>'
    };
    for (var i = 0; i < $assignedTo.length; i++) {
    var val = $assignedTo[i];
    $output += roleBadgeObj[val];
    }
    return '<span class="text-nowrap">' + $output + '</span>';
    }
    }

Sign In or Register to comment.