Loading too high... - Page 2

Loading too high...

2»

Replies

  • lifedaniellifedaniel Posts: 68Questions: 4Answers: 0

    Well, I don't even know that I use GET, how can I use POST? What's the difference?

    Thank you very much Allan.

  • lifedaniellifedaniel Posts: 68Questions: 4Answers: 0

    It says // Build our Editor instance and process the data coming from _POST

    and I put "TYPE": "POST" so I really don't know

  • lifedaniellifedaniel Posts: 68Questions: 4Answers: 0

    looks like my problem is USING serversided POST and EDITOR? Can't find any example with this working.. :(

  • lifedaniellifedaniel Posts: 68Questions: 4Answers: 0

    up

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    There is an example of using Editor with server-side processing here: https://editor.datatables.net/examples/simple/server-side-processing.html .

    Note specifically the DataTables Ajax initialisation:

        $('#example').DataTable( {
            ajax: {
                url: "../php/staff.php",
                type: "POST"
            },
            serverSide: true,
            ...
        } );
    

    There is also a server-side processing POST example here: http://datatables.net/examples/server_side/post.html .

    There are various other resources if you type "server-side processing POST" into the search box at the top of the page, but the above two should be sufficient.

    Allan

  • lifedaniellifedaniel Posts: 68Questions: 4Answers: 0

    isn't this exactly the same code as I gave you????? That isn't working

  • lifedaniellifedaniel Posts: 68Questions: 4Answers: 0

    And I have "DataTables warning: table id=datatabletest - Unknown field : index 0" as error

  • lifedaniellifedaniel Posts: 68Questions: 4Answers: 0
    edited August 2014

    I would also add that it's working with this server side script : http://datatables.net/examples/data_sources/server_side.html

    but not with the one I have with editor sever side...

    I'm sure my problem is from this file :

    <?php
    
    /*
     * Editor server script for DB table datatabletest
     * Automatically generated by http://editor.datatables.net/generator
     */
    
    // DataTables PHP library
    include( "lib/DataTables.php" );
    
    // Alias Editor classes so they are easy to use
    use
        DataTables\Editor,
        DataTables\Editor\Field,
        DataTables\Editor\Format,
        DataTables\Editor\Join,
        DataTables\Editor\Validate;
    
    
    // Build our Editor instance and process the data coming from _POST
    Editor::inst( $db, 'table' )
        ->fields(
            Field::inst( 'id' ),            
            Field::inst( 'nom' ),
            Field::inst( 'adresse' ),
            Field::inst( 'cp' )->validator( 'Validate::numeric' ),
            Field::inst( 'ville' ),
            Field::inst( 'pays' ),
            Field::inst( 'tel' ),
            Field::inst( 'fax' ),
            Field::inst( 'gsm' ),
            Field::inst( 'email' )->validator( 'Validate::email' ),
            Field::inst( 'tva' ),
            Field::inst( 'ctva' )   
        )
        
        ->process( $_POST ) 
        ->json();
        
    
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    isn't this exactly the same code as I gave you????? That isn't working

    Yes. But it is not the code that the example you linked to is using:

              "ajax": {
                  "url": "php/table.datatabletest.php", 
                
                                             
              },
    

    You said before that then you added type: 'POST' into there that it sorted working. I would like you to add it back in so I can take a look at the error.

    Allan

  • lifedaniellifedaniel Posts: 68Questions: 4Answers: 0

    So is it now, Cause I was working with WAMP sorry

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    There are a number of JS errors on the page:

    • Uncaught ReferenceError: Editor is not defined editor.title.js:45
    • Uncaught ReferenceError: editor is not defined (index):49
    1. Change Editor.models.fieldType to $.fn.dataTable.Editor.models.fieldType to resolve.
    2. Looks like a scope error for:
    editor.field('ctva').update( [
          '0%', '6%', '21%'
      ] );
    

    Allan

  • lifedaniellifedaniel Posts: 68Questions: 4Answers: 0
    edited August 2014

    Updated, still an error..

    note :

    the problem happen when I add type: "POST"

    to the

    ajax: {
    url: "php/table.datatabletest.php",

            },
    

    and if I don't, it loads all the data in the same page.

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    Okay good.

    So the problem is being cause by the use of:

    data: null

    in a couple of columns. If you replace that (for example in the first column) with id it will work.

    That is required for server-side processing since the server needs to be told what column to sort order when it is submitted for sorting (it can't sort on the rendered data, since you are doing the rendering on the client side in this case).

    Allan

  • lifedaniellifedaniel Posts: 68Questions: 4Answers: 0

    How can I replace {
    render: function ( data, type, row ) {
    // Combine the first and last names into a single table field
    return data.adresse+' '+data.cp+' '+data.ville;
    }
    },

    or

    {
    data: null,
    className: "center",
    defaultContent: '<center><a href="" class="editor_edit" title="Editer"><img src="images/edit.png" width="16" height="16" border="0"></a> <a href="" class="editor_view" title="Voir"><img src="images/view.png" width="16" height="16" border="0"></a> <a href="" class="editor_remove" title="Supprimer"><img src="images/delete.png" width="16" height="16" border="0"></a></center>'
    }

    by removing data : null?

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    I would leave the rendering function as you have it, but also assign a value to data - in the case of the first column id as I suggested above.

    Allan

  • lifedaniellifedaniel Posts: 68Questions: 4Answers: 0
    edited August 2014

    Kk for column with only one data it works, but for columns with concatenation, or options list like :

    {
                        data: null, render: function ( data, type, row ) {
                    
                        return data.adresse+' '+data.cp+' '+data.ville;
                        }
                    }
    

    OR

    {
                        data: null,
                        className: "center",
                        defaultContent: '<center><a href="" class="editor_edit" title="Editer"><img src="images/edit.png" width="16" height="16" border="0"></a>&nbsp;<a href="" class="editor_view" title="Voir"><img src="images/view.png" width="16" height="16" border="0"></a>&nbsp;<a href="" class="editor_remove" title="Supprimer"><img src="images/delete.png" width="16" height="16" border="0"></a></center>'
                    }
    
    

    dunno how to do it so it let me sort it after...

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    As I say, the server needs to know what data to sort on for that column. So you would set columns.data to whatever the database field name is that you want to sort on for that column. If you don't want sorting for that column, use columns.orderable to disable it.

    Allan

  • lifedaniellifedaniel Posts: 68Questions: 4Answers: 0

    Thank you very very much ! It works fine now ! :)

  • lifedaniellifedaniel Posts: 68Questions: 4Answers: 0

    up

  • lifedaniellifedaniel Posts: 68Questions: 4Answers: 0

    up

  • lifedaniellifedaniel Posts: 68Questions: 4Answers: 0

    up

This discussion has been closed.