Editor - New, Update - Checkbox group - C#

Editor - New, Update - Checkbox group - C#

david.j.meyer2@boeing.comdavid.j.meyer2@boeing.com Posts: 54Questions: 15Answers: 0

The checkbox's are not appearing in the form edit dialog for new or update.

Below is a sample of the JSON message being sent on Load. The table loads correctly and the editor form appears with the data populated except for the checkbox roles. In the table view the checkbox roles are concatenated into "|" delimited string. That is also working correctly. The problem is specifically with the form, the label for the checkbox shows but no check boxes are present. I have also included the Editor and DataTables JQuery from the page. This is a asp.net MVC applicaiton.

    "data":
        [{
            "ROLES":[{"label":"ADMIN","id":"ADMIN"},{"label":"DESIGN","id":"DESIGN"},{"label":"QUALITY","id":"QUALITY"}],
            "EmpID":"22",
            "Name":"Person, Two",
            "EMAIL":"PERSON.TWO@COMPANY.COM",
            "ROLE_LIST":"ADMIN|DESIGN|QUALITY"},{"ROLES":[{"label":"INSPECTION","id":"INSPECTION"}],
            "EmpID":"11",
            "Name":"Person, One",
            "EMAIL":"USER1@GMAIL.COM"
        }],
    "recordsTotal":2,"recordsFiltered":2,"draw":1,
    "options":
        [{
            "ROLES[].id":
                [{"label":"ANALYST","id":"ANALYST"},
                {"label":"DESIGN","id":"DESIGN"},
                {"label":"INSPECTION","id":"INSPECTION"},
                {"label":"QUALITY","id":"QUALITY"},
                {"label":"SUPER USER","id":"SUPER USER"},
                {"label":"ADMIN","id":"ADMIN"
                }]
        }]

        var editor = new $.fn.dataTable.Editor({
            dom: "Bfrtip",
            ajax:
            {
                create: {
                    type: 'POST',
                    url: '/App/Users/CreateContact'
                },
                edit: {
                    type: 'PUT',
                    url: '/App/Users/EditContact'
                },
                remove: {
                    type: 'DELETE',
                    url: '/App/Users/Remove'
                }
            },
            idSrc: "EmpID",
            table: "#appUsers",
            fields: [{
                type: "readonly",
                label: "Emp ID:",
                name: "EmpID"
            }, {
                type: "readonly",
                label: "Name:",
                name: "Name"
            }, {
                type: "readonly",
                label: "Email:",
                name: "EMAIL"
            }, 
            {
                label: "Roles:",
                name: "ROLES[].id",
                type: "checkbox"
            }]
        });


        var drawingTable = $('#appUsers').DataTable({
            dom: "Bfrtip",
            ajax: "/App/Users/GetUsers",
            "processing": true,
            "columns": [
                { "data": "EmpID" },
                { "data": "Name" },
                { "data": "EMAIL" },
                { "data": "ROLES", render: "[|].label" }],
            select: true
            ,
            buttons: [
                { extend: "create", editor: editor },
                { extend: "edit", editor: editor },
                { extend: "remove", editor: editor }
            ]
        });

Any help is greatly appreciated.

Thanks

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,118Questions: 1Answers: 2,583
    Answer ✓

    Note duplicate of this thread here.

This discussion has been closed.