checkbox options

checkbox options

Andreas S.Andreas S. Posts: 207Questions: 73Answers: 4

I have problems with the checkbox options. I used this example https://editor.datatables.net/examples/advanced/joinArray.html to implement it. But i dedected problems two problems.
1.
in the example the editor would send a field data[0][permission-many-count]=2. where does the field come from? In my implementation this field never comes in any cases.
2.
I have a server side script in java. I'm not sure to the send data format for the checkboxes is correct. No checkboxes are check, if the should checked. I append a part of the sending json file and the part in the editor. Anyone an idea whats wrong here in my code?

Andreas

here my code for the editor

usrForm = new $.fn.dataTable.Editor( {
    table: '#usrtbl',
    ajax: '/assets/php/api/users.php?usr=2',
    display: 'bootstrap',
    template: '#tplUser',
    fields: [
       {
    label: frmInfo.u_role,
    name: 'u_role',
    data: 'role.id',
    type: 'checkbox',
    optionsPair: {
        label: 'name',
        value: 'id'
    }
      ]
}

here my jsonformat that i send to the client

{
    "content": [{
        "DT_RowId": "a63bf953-f4a4-4927-b12b-011ee6eabba3",
        "_index": 1,
        "fullName": "BENIGNI Zita",
        "lastname": "Benigni",
        "firstname": "Zita",
        "lastnamePrefix": "",
        "birthday": "1974-03-05",
        "gender": "FEMALE",
        "nationality": {
            "iso3166_1_alpha2": "AT",
            "name": "Austria"
        },
        "email": "zita.benigni@chello.at",
        "club": {
            "uuid": "c4b1db94-31fd-4d5b-b611-71175b0321a3",
            "name": "Vienna Dolphins"
        },
        "status": "APPROVED",
        "uadress": {
            "adress1": "",
            "adress2": "",
            "zip": "",
            "state": "",
            "country": {
                "iso3166_1_alpha3": "",
                "name": ""
            },
            "location": ""
        },
        "maxChildren": 0,
        "language": "DE",
        "role": {
            "4": {
                "id": 4,
                "name": "Club"
            },
            "0": {
                "id": 0,
                "name": "User"
            }
        }
    },.....

    "recordsFiltered": 31,
    "recordsTotal": 76,
    "options": {
        "u_role": [{
            "name": "User",
            "id": "0"
        }, {
            "name": "Parent",
            "id": "1"
        }, {
            "name": "Athlete",
            "id": "2"
        }, {
            "name": "Coach",
            "id": "3"
        }, {
            "name": "Club",
            "id": "4"
        }, {
            "name": "Federation",
            "id": "5"
        }, {
            "name": "Administration",
            "id": "6"
        }]

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,431Questions: 1Answers: 10,048 Site admin
    Answer ✓

    data[0][permission-many-count]=2. where does the field come from? In my implementation this field never comes in any cases.

    From Editor itself. It sees the array in the value, so it sends the -many-count parameter as well to tell the server (otherwise there is no way to know if no items are selected, or just that that field was not submitted).

    If it isn't working for you, I'd need a link to your page showing the issue. Also make sure you are using the latest version of Editor.

    2

    This is an object:

            "role": {
                "4": {
                    "id": 4,
                    "name": "Club"
                },
                "0": {
                    "id": 0,
                    "name": "User"
                }
            }
    

    DataTables and Editor would generally expect an array there.

    Allan

This discussion has been closed.