Why doesn't the table pass data to sort columns ?

Why doesn't the table pass data to sort columns ?

izumovizumov Posts: 178Questions: 14Answers: 0

this is my test case.http://montaj.vianor-konakovo.ru/orders05.php?id=-1
The second table does not pass data to sort columns why?This is an ajax request to the server_processingorders013 script.php.Prompt in what a problem how to solve it?

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    Hi @izumov ,

    You're getting an error when you select a row, Cannot read property '0' of undefined , so you need to debug your script. I imagine this would be a good place to start:

    kodorder=kod[0][0];
    

    Cheers,

    Colin

  • izumovizumov Posts: 178Questions: 14Answers: 0

    bug fixed look at the work table now.And in your test example you can see that the search field and show crawl up to the top of the table why did this happen?

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    You've got serverSide enabled, so the sorting is the responsibility of your server side script.

  • izumovizumov Posts: 178Questions: 14Answers: 0

    absolutely fair.But server code needs data of this kind order[0][column]: 0
    order[0][dir]: desc and so on for other columns the problem is that the table in the ajax request does not send such data and it is not possible to sort the server

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    It is sending that to your script, check your network tab. See also your other threads, such as this one, you're asking the same question again!

  • izumovizumov Posts: 178Questions: 14Answers: 0

    Sorry, we're probably talking about different requests. On page 2 of the table. One left the FAC transmits the data of the second right-sends the request to the script server_processingorders013.php.So there is no required data in privage what goes in the header
    draw: 29
    columns[0][data]: 0
    columns[0][name]:
    columns[0][searchable]: true
    columns[0][orderable]: true
    columns[0][search][value]:
    columns[0][search][regex]: false
    columns[1][data]: 1
    columns[1][name]:
    columns[1][searchable]: true
    columns[1][orderable]: true
    columns[1][search][value]:
    columns[1][search][regex]: false
    columns[2][data]: 2
    columns[2][name]:
    columns[2][searchable]: true
    columns[2][orderable]: true
    columns[2][search][value]:
    columns[2][search][regex]: false
    columns[3][data]: 3
    columns[3][name]:
    columns[3][searchable]: true
    columns[3][orderable]: true
    columns[3][search][value]:
    columns[3][search][regex]: false
    columns[4][data]: 4
    columns[4][name]:
    columns[4][searchable]: true
    columns[4][orderable]: true
    columns[4][search][value]:
    columns[4][search][regex]: false
    order: 2
    start: 0
    length: 10
    search[value]: 2
    search[regex]: false
    _: 1559887978860

    I don't see the order parameter in this list
    I do not see in this list the order parameter indicating the number of the sorted column and the sorting direction in this form
    order[0][column]: 0
    order[0][dir]: desc

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    Your table only has a single page. Also, at the end of that list, you'll see order: 2 - this is the order the client is requesting, column 2.

  • izumovizumov Posts: 178Questions: 14Answers: 0

    I'll ask about the server code.I used to use this code to set sorting in a script
    $sqlRec .= " ORDER BY ". $columns[$params['order'][0]['column']]." ".$params['order'][0]['dir']." LIMIT ".$params['start']." ,".$params['length']." "
    Now this code generates an error due to the lack of parameters ['order'][0]['column'] and 'order'][0]['dir'].How do I define this data in a universal way? To make the script work correctly

  • izumovizumov Posts: 178Questions: 14Answers: 0

    In other words, to sort on the server side you need to know two parameters:the sorted column c number before I extracted it as ['order'][0]['column']now it does not come and the second parameter is the sorting direction. I extracted it as 'order'][0]['dir']now it also does not come how to do right?

  • izumovizumov Posts: 178Questions: 14Answers: 0

    the value of the number of the sorted value was passed well in the order parameter. And in what parameter the value of the sorting direction was transferred?

  • izumovizumov Posts: 178Questions: 14Answers: 0

    And also always sent order: 2 though I sort the first column

  • kthorngrenkthorngren Posts: 21,141Questions: 26Answers: 4,918
    Answer ✓

    Looks like you are changing the order parameter that Datatables is sending:

        $('#details').DataTable( {
             "order": [[ 0, "desc" ]],
             select: true,
             scrollY: true,
             scrollX:true,
             "sRowSelect": "single",
            "processing": true,
            "bPaginate": true,
            "bSort": true,
            "serverSide": true,
            "autoWidth":true,
            // "ajax": "proc.php"
            "ajax": {
            url:"server_processingorders013.php",
            data:function(d){d.order=kodorder;}  // <<< This is changing the order parameter.
            }
    
        
    
        } ) ;
    

    Remove the line I highlighted and I suspect you will see the parameters as you are expecting them.

    Kevin

  • izumovizumov Posts: 178Questions: 14Answers: 0

    Thanks your advice helped. I replaced the custom parameter order with id in the code and everything worked as it should

This discussion has been closed.