No saveing with serverSide: false

No saveing with serverSide: false

RappiRappi Posts: 77Questions: 17Answers: 1

Hello,
and another problem with the new version.
After the update you get into an infinite loop when saving (https://tiermanagement.rappi.de/table_paten_new.php) but only with serverSide:false;.

To see the problem select any row, click on "Edit" and than on "Speichern".

I had previously serverSide:false and would like to keep that for various reasons.

Here is my code:

<script>
                            /*
 * Editor client script for DB table tierart
 * Created by http://editor.datatables.net/generator
 */

(function($){

$(document).ready(function() {


    var editor = new $.fn.dataTable.Editor( {
        "ajax": "tiere_paten_processing.php?xid=<?php echo $xid; ?>",
        "table": "#tm_tiere_paten",
        "fields": [
            {
                "label": "Tier",
                "name": "tm_paten_tier.Tier",
                "def": "<?php echo $xid; ?>",
                "type": "hidden"

            },
            {
                "label": "Pate",
                "name": "tm_paten_tier.Pate",
                "type": "select"
            }
        ],
        i18n: {
            create: {
                button: "Neu",
                title:  "Neuer Eintrag",
                submit: "Eintragen"
            },
            edit: {
                button: "Edit",
                title:  "Eintrag editieren",
                submit: "Speichern"
            },
            remove: {
                button: "Löschen",
                title:  "Eintrag löschen",
                submit: "Löschen",
                confirm: {
                    _: "Wollen Sie wirklich %d Zeilen löschen?",
                    1: "Wollen Sie den Eintrag wirklich löschen?"
                }
            }
         }
    } );

    $('#tm_tiere_paten').DataTable( {

    language: {
            buttons: {
                colvis: "Anzuzeigende Spalten",
                colvisRestore: "Zurücksetzen"
            },
            paginate: {
                first:      "Erste",
                last:       "Letzte",
                next:       "Weiter",
                previous:   "Zurück"
            },
            search: "Suchen:",
            info: "Zeige _START_ bis _END_ von _TOTAL_ Einträgen",
            infoEmpty:      "Zeige 0 bis 0 von 0 Einträgen",
            emptyTable: "Keine Einträge vorhanden",
            decimal:        ",",
            thousands:      "."
        },
    "sPaginationType":"full_numbers",
        "dom": "B<'clear'>rt",
        serverSide: false,
        buttons: [
            { extend: "create", editor: editor },
            { extend: "edit",   editor: editor },
            { extend: "remove", editor: editor }
        ],
        "select": true,
        "ajax": "tiere_paten_processing.php?xid=<?php echo $xid; ?>",
        "columns": [
             {
                data: "tm_paten",
                render: function ( val, type, row ) {
                    return val.Name +', '+ val.Vorname;
                },
                defaultContent: ""
            },
            
        ],
    } );
} );

}(jQuery));
</script>

And here my serverscript

<?php
require_once("models/config.php"); 

$xid = $_GET["xid"]; 


// DataTables PHP library and database connection
include( "classes/DataTables.php" );

$db->sql("SET character_set_client=utf8");
$db->sql("SET character_set_connection=utf8");
$db->sql("SET character_set_results=utf8");

// Alias Editor classes so they are easy to use
use
    DataTables\Editor,
    DataTables\Editor\Field,
    DataTables\Editor\Format,
    DataTables\Editor\Mjoin,
    DataTables\Editor\Options,
    DataTables\Editor\Upload,
    DataTables\Editor\Validate;


// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'tm_paten_tier', 'id' )
    ->fields(
        Field::inst( 'tm_paten_tier.id' ),
        Field::inst( 'tm_paten_tier.Tier' )
            ->options( 'tm_tiere', 'id', 'Name' ),
        Field::inst( 'tm_tiere.Name' ),
        
        Field::inst( 'tm_paten_tier.Pate' )
                
                ->options( Options::inst()
                ->table( 'tm_paten' )
                ->value( 'id' )
                ->label( array('Name', 'Vorname') )
                ),

        Field::inst( 'tm_paten.Name' ),
        Field::inst( 'tm_paten.Vorname' ),
        
        Field::inst( 'tm_paten_tier.Betrag' ),
        Field::inst( 'tm_paten_tier.Intervall' ),
        Field::inst( 'tm_paten_tier.Art' )
            ->options( 'tm_patenart', 'id', 'Name' ),
        Field::inst( 'tm_patenart.Name' ),
        Field::inst( 'tm_paten_tier.Aktiv' ),
        Field::inst( 'tm_tiere.id' )
        
    )
    ->where('tm_paten_tier.Tier', $xid, '=')
    
    ->leftJoin( 'tm_tiere', 'tm_tiere.id', '=' , 'tm_paten_tier.Tier' )
    ->leftJoin( 'tm_paten', 'tm_paten.id', '=' , 'tm_paten_tier.Pate' )
    ->leftJoin( 'tm_patenart', 'tm_patenart.id', '=' , 'tm_paten_tier.Art' )
    
    ->process( $_POST )
    ->json();

What could be the reason for this?

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 13,788Questions: 25Answers: 3,243
    Answer ✓

    Look at the browser's console, you are getting this error:

    Uncaught TypeError: Cannot read property 'getDetails' of undefined

    Search the forum for the error and you will see threads like this one.

    Kevin

  • RappiRappi Posts: 77Questions: 17Answers: 1

    Thank you very much!
    This is now also running again. Hopefully there will be a fix for SearchBuilder soon, because that's what I wanted to use.
    Now I just have to get the speed under control. Since the update, a call of a page with a total of 6 tables takes about 8 seconds! This was not so before....
    Do you, or someone else, have a tip?

  • kthorngrenkthorngren Posts: 13,788Questions: 25Answers: 3,243

    The options to try increasing the speed of Datatables are listed in this FAQ.

    Kevin

  • RappiRappi Posts: 77Questions: 17Answers: 1

    I have optimized everything.
    By chance, however, I just noticed that in the current Edge everything goes fast as usual. Only in Chrome it takes 8 seconds until the page is loaded.
    That was not the case before. If I test an old installation, then it also goes fast in Chrome.
    Now I am at a loss....

  • colincolin Posts: 12,617Questions: 0Answers: 2,156

    @Rappi Have you resolved it since your last post? I tried your link, https://tiermanagement.rappi.de/table_paten_new.php , and everything is loading and updating as expected.

    Colin

  • RappiRappi Posts: 77Questions: 17Answers: 1

    Hello Colin,

    the problem occurs in the production environment.

    but i have created a test page where you can see it very nicely (https://tiermanagement.rappi.de/modules/Tier-Management/table_new.php).
    It takes about 7-8 seconds to load all the data. Scroll down to see all data.

    However, only with Chrome.
    With Edge it takes about 2 seconds. Likewise with Firefox, Vivaldi and Blisk.

    What was changed in DataTables that Chrome suddenly gets a problem?

  • colincolin Posts: 12,617Questions: 0Answers: 2,156

    I just tried it here with the link you posted, on Ubuntu, with the latest FF and Chrome, and both load within a couple of seconds. Have you tried it in Incognito on Chrome, in case any extensions are causing interference.

    Nothing inside DataTables has changed to cause such an effect, so it would be worth debugging locally, especially given it appears to work at the same speed on Linux.

    Colin

Sign In or Register to comment.