Natural Sort not working with the nightly build
Natural Sort not working with the nightly build
Hi guys,
I am making a gradebook table and the columns that are displaying student grades look like this: "120pts (87%)." In order to successfully do sorting on these columns I implemented the natural sort referenced in this forum post:
http://datatables.net/forums/discussion/comment/21622
This all works great with version 1.9.4. However there is a bug in 1.9.4. which makes column reordering not work when used in conjunction with fixedColumns. You can see the bug in this video:
http://screencast.com/t/JzlsUercRi7A
I believe it is known bug but basically if you try to move a column all the way next to the fixed column it causes the error. I think I read someplace in your forums that it has something to do with hidden vs. visible columns. In any case I decided to use your nightly builds to try and fixed the issue and indeed the nightly build do take care of this bug. However the code I wrote for natural sort does not work anymore. I was wondering if you can tell me what was changed in the nightly builds that breaks my natural sort code and what do I need to do to fix it. The way I do it now is I overwrite the string-asc and string-desc behavior like this:
[code]jQuery.fn.dataTableExt.oSort['string-asc'] = function (a, b) {
return naturalSort(a, b);
};
jQuery.fn.dataTableExt.oSort['string-desc'] = function (a, b) {
return naturalSort(a, b) * -1;
};[/code]
What do I need to change to make the naturals sort work with the nightly builds?
I am making a gradebook table and the columns that are displaying student grades look like this: "120pts (87%)." In order to successfully do sorting on these columns I implemented the natural sort referenced in this forum post:
http://datatables.net/forums/discussion/comment/21622
This all works great with version 1.9.4. However there is a bug in 1.9.4. which makes column reordering not work when used in conjunction with fixedColumns. You can see the bug in this video:
http://screencast.com/t/JzlsUercRi7A
I believe it is known bug but basically if you try to move a column all the way next to the fixed column it causes the error. I think I read someplace in your forums that it has something to do with hidden vs. visible columns. In any case I decided to use your nightly builds to try and fixed the issue and indeed the nightly build do take care of this bug. However the code I wrote for natural sort does not work anymore. I was wondering if you can tell me what was changed in the nightly builds that breaks my natural sort code and what do I need to do to fix it. The way I do it now is I overwrite the string-asc and string-desc behavior like this:
[code]jQuery.fn.dataTableExt.oSort['string-asc'] = function (a, b) {
return naturalSort(a, b);
};
jQuery.fn.dataTableExt.oSort['string-desc'] = function (a, b) {
return naturalSort(a, b) * -1;
};[/code]
What do I need to change to make the naturals sort work with the nightly builds?
This discussion has been closed.
Replies
Yes - https://github.com/DataTables/DataTables/blob/master/examples/advanced_init/html5-data-attributes.html
It will be properly documented when it is released.
Thanks for noting the natural sort issue. I will look into it.
Allan
thank you very much for your prompt response. Thanks to your link I did manage to get sorting work via the data-sort attribute. this is great for me since the cell data in my table can have multiple formats based on user settings so defining an underlying sort field is essential for me.
However updating to nightly build files (jquery.dataTables.js, ColReorder.js and FixedColumns.js) broke the code I wrote that was properly resizing the table when the window is resized. My code for resizing is bellow:
[code]
$(window).smartresize(function () {
var height = CalculateHeight();
var oSettings = oTable.fnSettings();
oSettings.oScroll.sY = CalculateDataTableHeight(height);
oTable.fnAdjustColumnSizing();
oTable.fnDraw();
});[/code]
The CalculateDataTableHeight method basically takes the available height and adjusts it to take into account the footer rows I have in my table. This worked fine before as you can see in this video:
http://screencast.com/t/JjfjqQ2hXnJO
However when I update the scripts to the nightly build versions this is not working anymore. Here is the video of that:
http://screencast.com/t/IqBUNTtE
Do you have idea why is this happening and what do I need to do to redraw the table if the window size is changed? I looked an number of solutions both here and on Stackoverflow but none of them are working with nightly build. Has something changed with regards to how sScrollY property works?
Allan
thanks for the update. I think for now I will just AJAX reload the entire table container every time the user resizes the screen. It's not very efficient approach but I think that is much less likely to happen than the issue with reordering columns when the 1st column is fixed which the nightly build fixed for me.
If you find the solution for the issue please let me know... And keep up the good work!!! :)
Marko