checkbox editor allways hide

checkbox editor allways hide

solutekasoluteka Posts: 2Questions: 2Answers: 0
edited April 2019 in Free community support

Hi All

We are using the licensed datables editor and some of our tables have boolean columns, we could not make the editor work as a checkbox. In spite of following each one of the instructions of the documentation and forums.
They appear in the datatable but not in the editor to update the values of the column.
this is the sentence in the editor

            editor = new $.fn.dataTable.Editor({
                ajax: function (method, url, d, success, error) {
                    var output = { data: [] };
                    if (d.action === 'edit') {
//...           
         }
                    if (d.action === 'create') {
   //...
                 }
                    if (d.action === 'remove') {
      .//..
              }
                },
                table: "#OwnTable",
                idSrc: "MiId",
                fields: [
                    { label: "Id:", name: "MiId", def: "0", attr: { disabled: true } }
                    , { label: "Email:", name: "email" }
                    , {
                        label: "Email confirmation:", name: "emailConfirmed",
                        type: "checkbox",
                        options: {
                            "Y": 1
                        },
                        separator: ','
                    }
                    , { label: "Phone:", name: "phoneNumber" }

                ],
                formOptions: {
                    inline: {
                        onBlur: 'submit'
                    }
                },
                 error: {
                        system: 'Errors  ocurred.'
                    }
                }
            });
and de datatable Code

      var ownTable = $('#MiTable').DataTable({
                dom: "Bfrtip",
                scrollX: true,
                paging: true,
                ajax: {
                    url: SERVICE_URL_BASE + '/Api/getmethod/' + auditid,
                    type: "GET",
                    dataType: 'json',
                    'content-Type': 'x-www-form-urlencoded',
                    , "dataSrc": function (json) {
                        return json;
                    }
                }
                columns: [
                    { "data": null, defaultContent: '', className: 'select-checkbox', orderable: false },
                    , { "data": "email" }
                    , {
                        "data": "emailConfirmed",
                        render: function (data, type, row) {
                            if (type === 'display') {
                                //return '<input type="checkbox" class="editor-emailConfirmed">';
                                return (data === true) ? 'Y' : 'N';
                            }
                            return data;
                        },
                        className: "dt-body-center"
                    }
                    , { "data": "phoneNumber" }
                ]
                ,
                autoFill: {
                    columns: ':not(:first-child)',
                    editor: editor
                },
                keys: {
                    columns: ':not(:first-child)',
                    editor: editor
                },
                select: {
                    style: 'os',
                    selector: 'td:first-child',
                    , blurable: true
                },
                order: [1, 'asc'],
                buttons: [
                    { extend: "create", editor: editor },
                    { extend: "edit", editor: editor },
                    { extend: "remove", editor: editor },
                    {
                        extend: 'collection',
                        text: 'Exportar',
                        buttons: [
                            'copy',
                            'excel',
                            'csv',
                            'pdf',
                            'print'
                        ]
                    }
                ]

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,143Questions: 1Answers: 2,586
    Answer ✓

    Hi @soluteka ,

    It looks like a few things were wrong with your script, such as the options for the checkbox and the test in the columns.render. I've fixed them here, and I think this is doing what you're after.

    If not, please can you modify that example to demonstrate your problem.

    Cheers,

    Colin

This discussion has been closed.