How to debug Editor.php when sorting

How to debug Editor.php when sorting

DocNCDocNC Posts: 24Questions: 6Answers: 0

Hello
I have to write a modif in editor.php concerning sort (namely, sort by something else than a field);
I guess the simpler way is to extend
class Editor and modify ->process or modify _ssp_sort() function.

Unfortunately, Datatables don't call the server side when I sort columns.
here is my config: (its a json version of the conf, but after some js treatment, it works fine)

 "dtConfig": {
        "responsive": false,
        "dom": "Bfrtip",
        "select": true,
        "scrollY": "400px",
        "scrollX": "100%",
        "scrollCollapse": true,
        "paging": false,
        "deferRender": false,
        "buttons": [
            {
                "extend": "create",
                "editor": "XEDIT"
            },
            {
                "extend": "edit",
                "editor": "XEDIT"
            },
            {
                "extend": "remove",
                "editor": "XEDIT"
            }
        ],
        "language": {
            "url": "js/fr_fr.json"
        },
        "order": [
            [
                4,
                "desc"
            ]
        ],
        "columns": [
            {
                "label": "Nom",
                "data": "nom",
                "className": " editable default",
                "render": "render_Nom",
                "width": "10em"
            },
            {
                "label": "ID",
                "data": "identification",
                "className": " noedit",
                "width": "3em"
            },
            {
                "label": "F",
                "data": "facture",
                "className": "right noedit",
                "render": "$.fn.dataTable.render.number( '.', ',', 0, '','' )",
                "type": "num-fmt",
                "width": "4em"
            },
            {
                "label": "R",
                "data": "regle",
                "className": "right noedit",
                "render": "$.fn.dataTable.render.number( '.', ',', 0, '','' )",
                "type": "num-fmt",
                "width": "4em"
            },
            {
                "label": "Debit",
                "data": "debit",
                "className": "right noedit",
                "render": "$.fn.dataTable.render.number( '.', ',', 0, '','' )",
                "type": "num-fmt",
                "width": "4em"
            },
            {
                "label": "Descriptif",
                "data": "descriptif",
                "className": " editable default"
            }
        ],
        "ajax": {
            "url": "listes/vclients/vclients.php",
            "type": "POST"
        }
    },

When I sort by any column (but the 'nom') everything is fine and the table is sorted. But neither the js renders nor the vclients.php are called;
I try a $(table).DataTable().rows().invalidate(); and it doesnt help.
I of course set debug(true) in vclients.php" with no better luck.

// Build our Editor instance and process the data coming from _POST
// $db is build by Datatables.php using $sqldetails
Editor::inst($db, $table, $primaryKey)
    ->debug(true, "editor.json")
    ->fields(
        Field::inst('nom')
            ->getFormatter('format_Nom')
            ->setFormatter('format_Nom'),
        Field::inst('identification'),
        Field::inst('facture')
            ->validator(Validate::numeric())
            ->setFormatter(Format::ifEmpty(null)),
        Field::inst('regle')
            ->validator(Validate::numeric())
            ->setFormatter(Format::ifEmpty(null)),
        Field::inst('debit')
            ->validator(Validate::numeric())
            ->setFormatter(Format::ifEmpty(null)),
        Field::inst('descriptif')
 )
   
    ->process($_POST)
    ->json();

Im a bit lost about how to 'clear cache' of Datatable ? or force it to call the serverside .php in order to debug the process.
thanks for your help !
Michel

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,142Questions: 1Answers: 2,586
    Answer ✓

    It looks like you haven't specified serverSide in the table's initialisation - so as far as DataTables is concerned all sorting/filtering/paging will be done on the client.

    Colin

  • DocNCDocNC Posts: 24Questions: 6Answers: 0
    edited June 2021

    I try to double check but the initial loading is done.... seems strange

    YOU ARE RIGHT.
    Im so sorry about that.
    thanks for helping
    MJ

Sign In or Register to comment.