different white-space behavior

different white-space behavior

robertbrowerrobertbrower Posts: 158Questions: 1Answers: 0
edited March 2014 in General
I have page with 2 data tables. One gets it's data from a web service via server side paging query. The query returns some column data that contains trailing white spaces. This is good, because I need them. The datatable shows the trailing whitespace.

The other datatable is populated when the page loads in my asp.net aspx file. It's white space gets trimmed, I presume when the datatable gets created. How can I prevent this? I need those trailing white spaces as these values are used as filters in my query.

Having to convert spaces to and from   is a real pain.

Thanks.

Robert

Replies

  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin
    DataTables does a trim on data it reads, but only if it has read it from the HTML. If it is Ajax sourced, as your comment suggests, it just uses the data as given.

    I think I'd need to see a test case to be able to say much more than that.

    Allan
  • robertbrowerrobertbrower Posts: 158Questions: 1Answers: 0
    "DataTables does a trim on data it reads, but only if it has read it from the HTML."

    Understood. How can I prevent the trimming of data that the datatable plugin does when it reads from the HTML?

    Thanks.

    Robert
  • robertbrowerrobertbrower Posts: 158Questions: 1Answers: 0
    edited March 2014
    I've got a workaround which is to render an empty HTML table, and in my page plugin, create the options object for the datatable plugin and conditionally set the aaData option if an javascript array that i pass into my page contains any data, then pass the options object to datatables. Thank you Allan.
  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin
    > How can I prevent the trimming of data that the datatable plugin does when it reads from the HTML?

    Its a hardcoded operation - you'd need to modify DataTables I'm afraid. Search for `$.trim` - its the only thing the trim is used for I think.

    Interesting - I think this is the first time I've been asked how to turn that off! I put it in in the first place to try and make filtering simpler...

    Good to hear you have a workaround though.

    Allan
This discussion has been closed.