Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82238

Cannot read property 'column' of undefined

$
0
0

I randomly get this error, when i'm editing inline using serverside true

When I disable it, I don't have that issue. This is very random so I can't find out what the issue is.

When serverside true is removed, I don't get that problem.

Any reason to this?

<table id="products" class="display" cellspacing="0" width="100%">
                                <thead>
                                    <tr>
                                        <th>ID</th>
                                        <th>Image</th>
                                        <th>Title</th>
                                        <th>Description</th>
                                        <th>Availability</th>
                                        <th>Price</th>
                                        <th>Shipping Price</th>
                                        <th>Edit / Delete</th>
                                        <th>Checkbox</th>
                                    </tr>
                                </thead>
                                <tfoot>
                                    <tr>
                                        <th>ID</th>
                                        <th>Image</th>
                                        <th>Title</th>
                                        <th>Description</th>
                                        <th>Availability</th>
                                        <th>Price</th>
                                        <th>Shipping Price</th>
                                        <th>Edit / Delete</th>
                                        <th>Checkbox</th>
                                    </tr>
                                </tfoot>
                            </table>

editor = new $.fn.DataTable.Editor( {
    ajax: "sw/load/ld-edit-table.php",
    table: "#products",
    fields: [ 
        {
            label: "ID:",
            name: "sw_gm_feed.gm_id",
            type: "readonly"
        }, {
            label: "Title:",
            type:  "textarea",
            name: "sw_gm_feed.title"
        }, {
            label: "Description:",
            type:  "textarea",
            name: "sw_gm_feed.description"
        }, {
            label: "Availability:",
            name: "sw_gm_feed.availability",
            type: "select",
            options: [
                 { label: "In Stock", value: "in stock" },
                 { label: "Out of Stock", value: "out of stock" }
            ]
        }, {
            label: "Price:",
            name: "sw_gm_prices.price"
        }, {
            label: "Shipping Price:",
            name: "sw_gm_shipping_prices.shipping_price"
        }
    ]
} );

editor
    .on( 'open', function ( e, type ) {
        if ( type === 'inline' ) {
            // Listen for a tab key event when inline editing
            $(document).on( 'keydown.editor', function ( e ) {
                if ( e.keyCode === 9 ) {
                    e.preventDefault();

                    // Find the cell that is currently being edited
                    var cell = $('div.DTE').parent();

                    if ( e.shiftKey && cell.prev().length && cell.prev().index() !== 0 ) {
                        // One cell to the left (skipping the first column)
                        cell.prev().click();
                    }
                    else if ( e.shiftKey ) {
                        // Up to the previous row
                        cell.parent().prev().children().last(0).click();
                    }
                    else if ( cell.next().length ) {
                        // One cell to the right
                        cell.next().click();
                    }
                    else {
                        // Down to the next row
                        cell.parent().next().children().eq(1).click();
                    }
                }
            } );
        }
    } )
    .on( 'close', function () {
        $(document).off( 'keydown.editor' );
    } );

$('#products').on( 'click', 'tbody td:not(:first-child)', function (e) {
    editor.inline( this, {
        submitOnBlur: true
    } );
} );

$('#products').dataTable( {
    dom: "Tfrtip",
    ajax: {
        url: "sw/load/ld-edit-table.php",
        type: 'POST'
    },
    serverSide: true,
    stateSave: true,
    columns: [
        { data: "sw_gm_feed.gm_id", "class":"gm_id" },
        {
            "bSearchable": false,
            "orderable": false,
            "class":"thumb-loading",
            "targets": 0,
            "data": "sw_gm_feed.image",
            "render": function ( data, type, full, meta ) {
              return '<img class="thumb" src="'+data+'">';
            }
          },
        { data: "sw_gm_feed.title" },
        { data: "sw_gm_feed.description" },
        { data: "sw_gm_feed.availability" },
        { data: "sw_gm_prices.price" },
        { data: "sw_gm_shipping_prices.shipping_price" },
        {
            bSearchable: false,
            orderable: false,
            data: null,
            defaultContent: '<button type="button" class="btn btn-primary edit"><i class="fa fa-pencil"></i></button> <button type="button" class="btn btn-secondary delete"><i class="fa fa-trash-o"></i></button>',
            width: '100px'
        },
    {
            bSearchable: false,
            orderable: false,
            data: null,
            defaultContent: '<input type="checkbox" class="selected" />',
            width: '50px'
        }
    ],
    tableTools: {
        sRowSelect: "os",
        aButtons: [
            { sExtends: "editor_edit",  sButtonText: "Quick Editing", editor: editor }
        ]
    }
} );

Viewing all articles
Browse latest Browse all 82238

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>