How to avoid trimmed the leading unwanted space of data in table cell
How to avoid trimmed the leading unwanted space of data in table cell

Hello! is anyone here got the solution in this issue? my question is related to this post https://datatables.net/forums/discussion/13657/leading-spaces-are-getting-trimmed-for-table-data
Please help guys. Thanks
This discussion has been closed.
Answers
Hi @okayee ,
Nothing's changed since that post, you'll need to modify the source - a benefit of open-source libraries!
Cheers,
Colin
Hello @colin ,
Thanks for the response but I already modify the source. I can't found the function that triggered the trimming of the value of the data in the cell. Please help to locate thanks
I check the link indicated that @allan indicated in the post. this is the line 628 here
This it : https://github.com/DataTables/DataTablesSrc/blob/5b2708dd876696311f76d20d26c2e312a3611041/js/core/core.data.js#L621 . We've updated the link in the original thread you pointed at too.
Colin
Hi @colin
Thank you for this. I will try to update my datatables components. I will update this thread once I already ork this out.
Hello @colin
Base on the link you suggest, Im only using this plugins of datatables
datatables.net/datatables.min.js
datatables.net/js/jquery.dataTables.js
datatables.net-bs/js/dataTables.bootstrap.min.js
datatables.net/buttons.html5.js
CDN's for export
https://nightly.datatables.net/buttons/js/buttons.print.min.js
https://nightly.datatables.net/buttons/js/buttons.flash.min.js
https://nightly.datatables.net/buttons/js/dataTables.buttons.min.js
https://nightly.datatables.net/buttons/js/buttons.colVis.min.js
https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js
https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js
https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js
That's all. now base on the link you suggest. I have no idea where I need to edit and remove the trimming of data in the table.
I don't think there is such a file is there? This is the repo for that package.
Here - search for
$.trim
to find the line that Colin linked to above.Out of interest - why do you not want to trim the white space from the HTML table? The white space messes with sorting and filtering.
Allan
Hello @allan
I remove all of the $.trim in all of my datatables plugins including the export plugins of datatable but it's still trimming the data. Even in the export file.
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
Buttons have their own strip via the
buttons.exportData()
options. I wasn't aware you were using buttons. As Colin says, we'd need a link to a test case and a full explanation of what you are trying to do to offer any further help.Allan
Hello @allan and @colin
Thank you for the response but can you please provide a datatables.live with a disabled trim for this issue?
For this issue I just need to disable the trimming of data in the table. its not a problem when using sort in the table. it happends that I need to show what is the format of the actual data. even if there is a extra spaces on it.
I was wondering if this option has been added. I to need a way to disable trimming from the data tables since it is altering the original value and making it difficult to reconcile it by to the database. Example: I have button to delete an entry using the value it get from the datatable, because the value was trimmed it now differs from the one that was stored in the database. This cause the process to failed because it is unable to find the entry in the database. I have try to altering the JavaScript for the datatable but that did not affect the value being trimmed. Any suggestion would help
I was able to do a workaround by adding the follow style to the html tag or added it to a stylesheet
<#name>{
white-space:pre;
}