sorting trouble: super-long HTTP request strings

sorting trouble: super-long HTTP request strings

GrantBGrantB Posts: 9Questions: 0Answers: 0
edited August 2012 in DataTables 1.8
I have a very wide table, 44 columns.

I'm finding that when I sort, the AJAX HTTP request string is *very* long, so much so that if I add a hidden column, it exceeds a server-configured length and the server rejects it.

Here's what that looks like:
[code]Started GET "/trades/search.datatables?sEcho=3&page=1&per_page=10&search%5Bmeta_sort%5D=quanty.desc&columns%5B0%5D=&columns%5B1%5D=&columns%5B2%5D=&columns%5B3%5D=quanty&columns%5B4%5D=&columns%5B5%5D=&columns%5B6%5D=&columns... etc etc etc[/code]
Which my server is interpreting as:
[code]Parameters: {"sEcho"=>"1", "page"=>"1", "per_page"=>"10", "search"=>{"meta_sort"=>".asc"}, "columns"=>{"0"=>"", "1"=>"", "2"=>"", "3"=>"quanty", "4"=>"", "5"=>"", "6"=>"", "7"=>"", "8"=>"", "9"=>"", "10"=>"", "11"=>"", "12"=>"", "13"=>"", "14"=>"", "15"=>"", "16"=>"", "17"=>"", "18"=>"", "19"=>"", "20"=>"", "21"=>"", "22"=>"", "23"=>"", "24"=>"", "25"=>"", "26"=>"", "27"=>"", "28"=>"", "29"=>"", "30"=>"", "31"=>"", "32"=>"", "33"=>"", "34"=>"", "35"=>"", "36"=>"", "37"=>"", "38"=>"", "39"=>"", "40"=>"", "41"=>"", "42"=>""}}[/code]

Note: I only provided an sName for "quanty", thus why the rest appear un-named.

It looks like datatables is sending the entire mapping of col-index to col-name to the server. Is this necessary?

(I see that "sServerMethod" is available to change it to POST, but it seems that my version of 1.8 does not have it.)

Replies

  • allanallan Posts: 63,678Questions: 1Answers: 10,497 Site admin
    I'd suggest using POST rather than GET here. As you say, sServerMethod can be used (introduced in 1.9.0, so you might want to upgrade). The other option is to override fnServerData with your own Ajax call.

    Allan
  • GrantBGrantB Posts: 9Questions: 0Answers: 0
    Well, this is awkward. I upgraded to 1.9.3, but it's still sending GETs, even with this:
    [code]"sServerMethod": "POST",[/code]

    Are there any known issues that could explain this?

    For more context, the full config is:
    [code]$("#trades_tbl").dataTable({
    "sAjaxSource" : "/trades/search.datatables",
    // "aaSorting" : [[0,'asc']], // sorting on initialization
    "bServerSide" : true,
    "fnServerData" : simpleDatatables,
    "bFilter" : false,
    "sServerMethod": "POST", // table size means the urls are really log

    "sDom" : "lfriptip",

    // pagination
    "aLengthMenu" : [10,50,100,500,1000],
    "bPaginate" : true,
    "bLengthChange" : true, // lets user choose number of records from menu
    "sPaginationType" : "input",

    "aoColumnDefs": [
    { "aTargets": ["id"], "bVisible":false },
    { "aTargets": ["quanty"], "sName":"quanty", "bSortable":true },
    { "aTargets": ["_all"], "bSortable":false, "bSearchable":false },
    ],
    });
    [/code]
  • allanallan Posts: 63,678Questions: 1Answers: 10,497 Site admin
    > "fnServerData" : simpleDatatables

    You are making your own Ajax call, so I presume that is doing GET rather than POST.

    Allan
  • GrantBGrantB Posts: 9Questions: 0Answers: 0
    edited August 2012
    Yep, I just spotted it a minute ago, and hacked a fix in for it. Thanks for your help.

    (The simple_datatables gem is the beginning of something nice for Rails users, but it's just not quite all the way there.)
  • shyamsunderkushwahashyamsunderkushwaha Posts: 1Questions: 0Answers: 0
    hi,
    i am using data table
    in which i use dwr.util.addRows() method to create row at run on ajaxRespose.
    the proble is that, when i do any text to search in table, or i click on sort button of any column,
    all row disappear and never comes back.
  • GrantBGrantB Posts: 9Questions: 0Answers: 0
    shyamsunderkushwaha, you should probably start a new discussion topic, as your issue seems unrelated to this one and people won't notice your post.
This discussion has been closed.