how to get pageLength and displayStart on controller side?

how to get pageLength and displayStart on controller side?

ravs2510ravs2510 Posts: 3Questions: 1Answers: 0
edited January 2016 in Free community support

Hi everyone,

I am using jquery datatable 1.10

Problem :-
I am using jquery data-table with server side processing but on controller side i am not able to get pageLength and displayStart
everytime it is 0.
Can any one please help me to figure it out?

I am using below mentioned code of script

<script type="text/javascript">
$(document).ready(function() {
    $('#<portlet:namespace/>orderTable').DataTable({
        "processing": true,
        "serverSide": true,
        "searching": true,
        "paging": true,
        "pageLength": 5,
        "lengthChange": true,
        "lengthMenu": [ [5, 10, 25, 50, -1], [5, 10, 25, 50, "All"] ],
        "pagingType": "full_numbers",
        "displayStart": 10,
        "ajax": {
            "url":"${getOrderURL}",
            "dataSrc": "response",
            "type": "POST"
        },
        "columns": [
            { "data": "key", "orderable": true },
            { "data": "short_title", "orderable": true },
            { "data": "title", "orderable": false },
            { "data": "description", "orderable": false }
        ]
    });
});
</script>

controller code :-

Integer start=ParamUtil.getInteger(resourceRequest, "pageLength");
System.out.println("start : "+start);
System.out.println("length : "+ParamUtil.getInteger(resourceRequest, "displayStart"));

Thanks in Advance,

Thanks & Regards,
Ravi Darji

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • glendersonglenderson Posts: 231Questions: 11Answers: 29

    It's in the URL for a get, or the parameters for a post.

    You want to get the "start" and the "length" variables.

    So, please forgive, I'm not a PHP user, but I think you want something like $_POST["start"] and $_POST["length"]

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

    It doesn't look like PHP is being used. C# perhaps? Possibly Java or something else.

    You are posting to the server, so you would need to refer to your programming language's method of getting the POST parameters. Use the browser's debugging tools to confirm that the data is being submitted to the server.

    Allan

  • ravs2510ravs2510 Posts: 3Questions: 1Answers: 0

    Hey thanks glendersson
    And allan to guide me
    @allan
    I am using java

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

    I'm not sure why you rejected both answers above? Did you check using your browser's debug tools to see what parameters are being sent to the server?

    We can't offer any server-side language support in this forum - I know next to nothing about Java :-)

    Allan

This discussion has been closed.