how to implement .hide()?

how to implement .hide()?

ehardingeharding Posts: 15Questions: 7Answers: 0

i'm basically using the example code and want to hide a field i.e. where do I put editor.hide( 'apd_num' ); in the code below to hide the Position field.

thanks

var editor; // use a global for the submit and return data rendering in the examples

$(document).ready(function() {
    editor = new $.fn.dataTable.Editor( {
        ajax: "./php/volume_edit.php", 
        table: "#volume",
        fields: [ {
                label: "apd_num:",
                name: "aps_volume.apd_num",
                def: "<?php echo $wai;?>"
            }, {
                label: "agency:",
                name: "aps_volume.agency",
                def: "<?php echo $agency_code;?>"
            }, {
                label: "parent:",
                name: "aps_volume.parent",
                def: "<?php echo $parent_code;?>"
            }, {
                label: "location:",
                name: "aps_volume.location",
                def: "<?php echo $location;?>"
            }, {
                label: "LOB:",
                name: "aps_volume.lob",
                type: "select",
                placeholder: "Select a line of business"
            }, {
                label: "Year:",
                name: "aps_volume.year",
                type:  "select",
                options: [
                    { label: "2016", value: "2016" },
                    { label: "2015", value: "2015" },
                    { label: "2014", value: "2014" }
                ]
            }, {
                label: "Actual:",
                name: "aps_volume.actual"
            }, {
                label: "Projection:",
                name: "aps_volume.projection"
            }, {
                label: "Comments:",
                name: "aps_volume.vcomments"
            }
        ],
        
        formOptions: {
            inline: {
                onBlur: 'submit'
            }
        }
    } );
    
    var table = $('#volume').DataTable( {
        dom: "Bfrtip",
        ajax: "./php/volume_edit.php",
        columns: [
            {
                data: null,
                defaultContent: '',
                className: 'select-checkbox',
                orderable: false
            },
            { data: "aps_volume.lob" },
            { data: "aps_volume.year" },
            { data: "aps_volume.actual", render: $.fn.dataTable.render.number( ',', '.', 0, '$' ) },
            { data: "aps_volume.projection", render: $.fn.dataTable.render.number( ',', '.', 0, '$' ) },
            { data: "aps_volume.vcomments"}
        ],
        order: [ 1, 'asc' ],
        keys: {
            columns: ':not(:first-child)',
            keys: [ 9 ]
        },
        select: {
            style:    'os',
            selector: 'td:first-child'
        },
//      select: true,
        buttons: [
            { extend: "create", editor: editor },
            { extend: "edit",   editor: editor },
            { extend: "remove", editor: editor }
        ]
    } );

    // hide fields
    $('#volume'){   
        editor
            .title('Edit Volume Data')
            .field('apd_num').hide();
    };
    
    // Inline editing on click
    $('#volume').on( 'click', 'tbody td:not(:first-child)', function (e) {
        editor.inline( this );
    } );

    // Inline editing on tab focus
    table.on( 'key-focus', function ( e, datatable, cell ) {
        editor.inline( cell.index() );
    } );
    
} );

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,087Questions: 1Answers: 10,386 Site admin
    Answer ✓

    If you want it to always be hidden, you could just use the hidden field type. To do that just add type: 'hidden' to that field.

    Allan

  • ehardingeharding Posts: 15Questions: 7Answers: 0

    thanks, that worked!

This discussion has been closed.