Editor serverside load all the records instead just the ones needed

Editor serverside load all the records instead just the ones needed

gkarimskgkarimsk Posts: 4Questions: 2Answers: 0
edited November 2015 in Editor

Hi everybody,
I bought recently the editor, and I'm not able anymore to interact correctly with mysql dB.
At the init it download all the records, instead of just the 25 i asked for the pagination.
With iDisplayLength I'm able to visualize just them, solving the problem of paginating, but still after It downloaded all the records (10.000). Also I have to use bserverside: true (?) insted o serverside:true, or It doesn't work at all.
I was able to do the same process without editing in Datatables, and it work. I see that the php library is different, I'll try with the total record and filtered record, but nothing.
I used the configurator to create the dummy structure and I work on it.

this is my code:
var table = $('#MyTable').DataTable( {

    ajax: 'php/table.MyTable.php',
        bProcessing: true,
        bserverSide: true,
        biDisplayLength : 10,

    columns: [
        {
            "data": "campo1"
        },
        {
            "data": "campo2"
        },
        {
            "data": "campo3"
        },
        {
            "data": "campo4", render: $.fn.dataTable.render.number( '.', ',', 2, '€ ' ) 
        }
    ],
    select: true


} );

Here a working example:

http://www.geodipe.it/dataLab/wp-content/plugins/DataTablesEditor2/OPERE_OUT.html

any suggestion?

This question has an accepted answers - jump to answer

Answers

  • gkarimskgkarimsk Posts: 4Questions: 2Answers: 0
    edited November 2015

    ...

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Answer ✓

    Try using:

    serverSide: true,
    ajax: {
      url: 'php/table.MyTable.php',
      type: 'POST'
    }
    

    See also this example.

    Allan

  • gkarimskgkarimsk Posts: 4Questions: 2Answers: 0

    Thanx Allan,
    that solved the problem.
    Just to understand it's a matter of asynchronous call?

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    It is an async call, yes, but the issue with the initial code was:

    1. The data wasn't being POSTed (which you would typically want with the Editor libraries)
    2. A typo in bServerSide (serverSide is the "modern" option to use anyway)

    Allan

This discussion has been closed.