serverside order doesn't work.

serverside order doesn't work.

mountain0714mountain0714 Posts: 1Questions: 1Answers: 0
edited September 2021 in DataTables

Link to test case:
Debugger code (debug.datatables.net):

Error messages shown:
Description of problem:

I am looking up a table using jpa native query. But the paging function works fine, but when I click on the filter on the screen, the data is sorted and not appearing in the datatable. The problem with this is that :sSortDir_0 etc doesn't work when running native queries on the repository.
All functions except sort work fine for my table. But I don't know why it can't just sort

=================my code
repo<nativeQuery>
+ "......"
+ "ORDER BY :sCoulmn :sSortDir_0 \r\n"
+ "LIMIT :iDisplayStart, :iDisplayLength")

service

public PagingVO selectPersonalTableByDate(Integer userSid, String searchStartDt, String searchEndDt, 
            int iDisplayStart, int iDisplayLength, String sSortDir_0, int iSortCol_0){
        PagingVO pagingVO = new PagingVO();
        iSortCol_0 = 2;
        pagingVO.setRecordsTotal(repo.selectTotalCountPersonal(userSid,searchStartDt, searchEndDt));
        pagingVO.setIDisplayStart(Integer.toString(iDisplayStart));
        pagingVO.setIDisplayLength(Integer.toString(iDisplayLength));
        String[] columns = new String[]{"AA.schdlCdNm","AA.schdlNm","AA.dt","AA.loc","AA.cmpy","AA.trnsp","AA.content"};
        String sCoulmn = columns[iSortCol_0];
        pagingVO.setData(repo.selectPersonalTableByDate(userSid, searchStartDt, searchEndDt, iDisplayStart, iDisplayLength, sSortDir_0, sCoulmn));
               return pagingVO;
    }

js

    $("#personalTable").DataTable({
        processing: true, 
        aLengthMenu: [[15, 25, 50], [15, 25, 50]],
        iDisplayLength: 15,
        serverSide: true,
        responsive: true,
        "searching": false,
        sAjaxSource : "/personal/selectPersonalTableByDate?&searchStartDt="+searchStartDt+"&searchEndDt="+searchEndDt,
        sServerMethod: "GET",
        columns : [
            {data: "schdlCdNm", width:"7%"},
            {data: "schdlNm", width:"10%"},
            {data: "dt", width:"22%"},
            {data: "loc", width:"13%"},
            {data: "cmpy", width:"13%"},
            {data: "trnsp", width:"10%"},
            {data: "content", width:"25%"}
        ]
    });

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

Answers

  • allanallan Posts: 61,431Questions: 1Answers: 10,048 Site admin

    The problem with this is that :sSortDir_0 etc doesn't work when running native queries on the repository.

    I'm not familiar with the server-side code you are using there, so I'm afraid I don't know why that would be. You'd need to get in touch with the author of the library you are using, of if it is your own software, debug why the sort parameter isn't being used.

    Allan

Sign In or Register to comment.