Converting old datatable code

Converting old datatable code

burton666burton666 Posts: 2Questions: 2Answers: 0
edited May 2019 in Free community support

I have just started to use Datatables and I am trying to convert some old datatables-code to be able to catch datatable-ajax-errors. When I use the original DataTables 1.10.4 the code works but the error-catching does not as it was introduced in 1.10.5. When I upgrade to 1.10.5 or newer the code stops working and I get this error: "Uncaught TypeError: Cannot read property 'cell' of undefined"

js

var table = $('#changes')
        .DataTable(
            {
                "language": {
                    "url": "http://cdn.datatables.net/plug-ins/3cfcc339e89/i18n/Swedish.json"
                },
                "searching" : false,
                "bProcessing" : false,
                "sAjaxSource" : "https://<url>/change",


                "sAjaxDataProp" : "mData",
                "aaSorting" : [ [ 0, "desc" ] ],
                "aoColumns" : [
                    {
                        "mData" : "id", "sType": "natural"
                    },
                    {
                        "mData" : "datum", "sType": "natural"
                    },
                    {
                        "mData" : "komponent", "sWidth": '30%', "sType": "natural"

                    },
                    {
                        "mData" : "ansvarig","sType": "natural"
                    },
                    {
                        "mData" : "beskrivning", "sType": "natural",
                        "mRender" : function(mData, type, full) {
                            console.log('Type: ' + type + 'Full: ' + full);
                            return '<div class="truncateBeskrivning" style="text-overflow:ellipsis;">'
                                + mData + '</div>';
                        }
                    }, {
                        "className" : 'details-control',
                        "orderable" : false,
                        "mData" : null,
                        "defaultContent" : ''
                    } ],
            });

html

<div class="panel panel-default">
            <div class="panel-body">
                <div class="row">
                    <div class="col-md-6 form-group">
                        <input id="search" placeholder="Sök..." class="form-control">
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-12">
                        <table id="changes" class="display">
                            <thead>
                                <tr>
                                    <th>Id</th>
                                    <th>Datum</th>
                                    <th>Komponent</th>
                                    <th>Ansvarig</th>
                                    <th>Beskrivning</th>
                                    <th></th>
                                <tr>
                            </thead>
                            <tbody></tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>

Answers

  • colincolin Posts: 15,146Questions: 1Answers: 2,587

    Hi @burton666 ,

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.