Using server side without ssp class

Using server side without ssp class

redaniredani Posts: 70Questions: 1Answers: 0

Hi Allan, hope you're doing well.
I'd like to ask you if there is any script sample for server side without the ssp class. I've noticed that I can use some GET variables such as start, length, ... but it'll be nice to have a sample.

Thanks a lot
Regards

Replies

  • allanallan Posts: 63,356Questions: 1Answers: 10,444 Site admin

    The SSP class is my demo script for server-side processing. I don't have any other's. If you needed it without a class you could dissect the class and build a simple linear function.

    Allan

  • redaniredani Posts: 70Questions: 1Answers: 0

    Thanks Allan for your fast reply.

    OK, i'll do that.
    Have a great week

  • redaniredani Posts: 70Questions: 1Answers: 0

    Hi again, I'm trying to implement the server side and have the following questions pls:

    1- I've noticed that in addition to Dara, I need to return draw, recordsTotal and recordsFiltered.
    1.1- how can I tell the value of draw?
    1.2- do you think I'll need another SQL query to get the value of recordsTotal?

    2- I've also noticed that the ajax call is made on keydown, is it possible to use some kind of timeout to make the ajax call every 400ms for example?

    Thanks

  • allanallan Posts: 63,356Questions: 1Answers: 10,444 Site admin

    1.1- how can I tell the value of draw?

    See the server-side manual page for full details of what is sent and expected back.

    1.2- do you think I'll need another SQL query to get the value of recordsTotal?

    Yes

    2- I've also noticed that the ajax call is made on keydown, is it possible to use some kind of timeout to make the ajax call every 400ms for example?

    searchDelay.

    Allan

  • redaniredani Posts: 70Questions: 1Answers: 0
    edited March 2017

    Thanks again Allan for your reply.

    1- I'm almost done but paginations dont work, it always shows 1 page, I'm sure i must be missing something stupid!
    here is what I'm doing in my server side script:

    $data['draw'] = intval($_GET['draw']);
    
    // query to get total number of records
    SELECT COUNT(*) AS recordsTotal FROM ...
    $data['recordsTotal'] = $recordsTotal; // total number of records
    
    // query using filter/ search. $start and $length are the GET values sent through ajax
    SELECT firstname, lastname, ... FROM table .... WHERE search_condition LIMIT $start, $length
    $data['recordsFiltered'] = rowCount(); // total number of results
    
    // return all datatable data in json
    while {
        fetch resutls
    }
    

    What am I doing wrong? and how are the paginations calculated?

    3- Also I have noticed that in your examples you use: "processing": true, what is that for?

    4- is it possible to style the "Processing..." message by replacing it by a spinner for example?

    Thanks a lot

  • allanallan Posts: 63,356Questions: 1Answers: 10,444 Site admin

    That suggests that the LIMIT isn't being applied to the query you are using to get the data from the table (which I don't actually see above - it shows the queries for the record counts).

    Allan

  • redaniredani Posts: 70Questions: 1Answers: 0
    edited March 2017

    I'm sorry Allan, but i don't really understand you well!
    I'm using the LIMIT in the second query to get data, and it's always returning $length results only.
    In your example, if I search for "ra", it will return 26 results, that means you don't use LIMIT $start, $length in your query, right?

    So, how and where should I use $length?

  • allanallan Posts: 63,356Questions: 1Answers: 10,444 Site admin

    You need three queries:

    1. One which will get the number of rows unfiltered
    2. One which will get the number of rows filtered
    3. One which will get the data for the current page

    I see only 2 queries in the code above. However, it is hard to say exactly what is happening in the pseudo code since it isn't exactly what is running.

    Allan

  • redaniredani Posts: 70Questions: 1Answers: 0

    Great, it works like a charm :) thanks a lot ;)

  • redaniredani Posts: 70Questions: 1Answers: 0

    Allan, please one last question.
    I'm currently working on a project using Vue.js and was wondering if you're planning to release a version compatible with this library. If not, do you recommend any equivalent?

    Thanks

  • allanallan Posts: 63,356Questions: 1Answers: 10,444 Site admin

    I don't currently have any plans to release any Vue components, although it is certainly something I would like to look at in future. I haven't used Vue much myself, so I can't really give any recommendations I'm afraid.

    Allan

  • redaniredani Posts: 70Questions: 1Answers: 0

    OK, thank you very much Allan.

    Have a lovely night ;)

This discussion has been closed.