Update from Version 1.x to 2.x

Update from Version 1.x to 2.x

Andreas S.Andreas S. Posts: 208Questions: 74Answers: 4

I have updated the Editor to the last Version of it, but now i have a Problems with the create. I get after submiting a create action following JS error:

TypeError: Cannot read property 'DT_RowId' of null ....

With the old Version the Problem is not available. I think i have a problem with the editor Definition.

athForm = new $.fn.dataTable.Editor( {
        table: '#athtbl',
        ajax: '/assets/php/api/athletes.php?ath=2',
        display: 'bootstrap',
        template: '#tplAthlete',
        fields: [
            {
                label: frmInfo.a_uuid + ':',
                name: 'a_uuid',
                data: 'DT_RowId',
                type: 'readonly'
            },{
                label: frmInfo.a_lastname + ': <span class="txt-Red">*</span>',
                name: 'a_lastname',
                data: 'lastname'
            },{
                label: frmInfo.a_firstname + ': <span class="txt-Red">*</span>',
                name: 'a_firstname',
                data: 'firstname'
            },{
......

The DT_RowID is needed to show with the edit action. The edit and delete action works with no Problems

Any Idea how can i solve the JS error

Andreas

This question has accepted answers - jump to:

Answers

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

    Nothing obviously wrong there I'm afraid. Can you give me a link to your page please?

    Thanks,
    Allan

  • Andreas S.Andreas S. Posts: 208Questions: 74Answers: 4

    Send you the link with a PM

    Andreas

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    Hi Andreas,

    Apologies for the delay in getting back to you here. The data coming back from the server when creating a new row (from athletes.php) is not quite in the format that DataTables / Editor expects. Specifically currently you are returning:

    {
        "data": {
            "type": "success",
            "a_uuid": "7893aedf-45e6-4714-9a2c-d3b2ba9a6f0a",
            ...
        }
    }
    

    But data should be an array of objects:

    {
        "data": [{
            "type": "success",
            "a_uuid": "7893aedf-45e6-4714-9a2c-d3b2ba9a6f0a",
            ...
        }]
    }
    

    Is athletes.php using your own code, or our Editor PHP libraries?

    Allan

  • Andreas S.Andreas S. Posts: 208Questions: 74Answers: 4

    Thanks for the Information. athletes.php is my own code. It's interesting that version 1 can handle this

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    Do you have the legacyAjax parameter set perhaps? Support for that was removed in v2.

    Allan

Sign In or Register to comment.