Would like to understand how to make the primary key visible in this example

Would like to understand how to make the primary key visible in this example

prema770prema770 Posts: 37Questions: 11Answers: 0
edited October 2022 in Editor

Very grateful for any tips
Thanks very much

(function($){

$(document).ready(function() {
    var editor = new $.fn.dataTable.Editor( {
        //editor.field('id').show();
        ajax: 'php/table.ncoadmin.php',
        table: '#ncoadmin',
             **fields: [
            {
                "label":"Property ID",
                "name":"id"
            },**
            {
                "label": "vr_key:",
                "name": "vr_key"
            },
            {
                "label": "address_state:",
                "name": "address_state"
            },
            {
                "label": "address_city:",
                "name": "address_city"
            },
            {
                "label": "address_1:",
                "name": "address_1"
            },
            {
                "label": "address_2:",
                "name": "address_2"
            },
            {
                "label": "address_zip:",
                "name": "address_zip"
            }
        ]
    } );

    var table = $('#ncoadmin').DataTable( {
        ajax: 'php/table.ncoadmin.php',
        columns: [
            {
                "data": "id"
            },
            {
                "data": "vr_key"
            },
            {
                "data": "address_state"
            },
            {
                "data": "address_city"
            },
            {
                "data": "address_1"
            },
            {
                "data": "address_2"
            },
            {
                "data": "address_zip"
            }
        ],
        select: true,
        lengthChange: false
    } );

    new $.fn.dataTable.Buttons( table, [
        { extend: "create", editor: editor },
        { extend: "edit",   editor: editor },
        { extend: "remove", editor: editor }
    ] );

    table.buttons().container()
        .appendTo( $('.col-md-6:eq(0)', table.table().container() ) );
} );

}(jQuery));

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    Hi,

    Do you mean in the Editor form? Perhaps the readonly would do what you need?

    Allan

  • prema770prema770 Posts: 37Questions: 11Answers: 0

    Hi Allan!
    Thanks very much for the suggestion. Think I misrepresented the issue.
    It looks like DT automatically supresses the ID field. So ended up by
    // Make id field visible
    editor.add( {
    label: "PropertyID:",
    name: "id"
    } );

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    As in the id field would be removed from the field list? That shouldn't be happening and I can't think of any code in the library that would be causing that. If you are able to give me a link to a page showing the issue, I'd be happy to take a look.

    Allan

Sign In or Register to comment.