Number sorting problem 8 Years, 2 Months ago
|
Karma: 0
|
I can't get columns with numbers to sort correctly in ARi data tables. 20 will be shown before 3 and after 2,8 when trying to sort the table. I'm using csv as source, table type is "ARI Table sorter" and I've tried setting "Digit" as sorting type for the column with numbers. I'm a bit uncertain what the meaning of "Column index" is, but tried using just the column number counting from left. Any advice to get those numbers sortable?
I've installed latest versjon of joomla and Ari data tables.
Url to table with problems: www.framtiden.no/gronne-tips/mat/klimagassutslipp-fra-matvarer.html
Best regards,
|
|
|
|
|
Re:Number sorting problem 8 Years, 2 Months ago
|
Karma: 760
|
Hello,
It is possible to sort this data type with help of "ARI Data Table" widget, but use . instead , in float numbers. Populate "Choose table type -> ARI Data Tables -> Columns settings -> Column index" parameter with zero-based column index (it means the first column will have 0 index, the second will have 1 index and etc.) and set "Columns settings -> Sorting type" parameter to "Numeric HTML" value.
Regards,
ARI Soft
|
|
|
|
|
Re:Number sorting problem 8 Years, 2 Months ago
|
Karma: 0
|
Is it possible to use comma instead for decimal numbers if some code or setting is changed? I can't use a period before decimals due to grammar rules in Norwegian.
Using "ARI Table sorter" there are no "Numeric HTML"-option for sorting type?
So rgd. the column index I just write add 0-1-2-3, for each column when there are four? Or add "0" for the columns with numbers?
|
|
|
Last Edit: 2016/11/02 18:19 By kehelle.
|
|
Re:Number sorting problem 8 Years, 2 Months ago
|
Karma: 760
|
It doesn't require to specify all columns in "Columns settings" parameters section. By default "text sorting type is used for all columns.
About using , instead . symbol, it requires to modify <joomla_directory>/modules/mod_aridatatables/includes/js/widgets/datatable/js/jquery.dataTables.extra.js file. Replace the following code:
Code: |
jQuery.fn.dataTableExt.oSort['num-html-asc'] = function(a,b) {
var x = a.replace(/[^-.0-9]/g, "");
var y = b.replace(/[^-.0-9]/g, "");
x = parseFloat( x );
y = parseFloat( y );
if (isNaN(x))
x = Number.MAX_VALUE;
if (isNaN(y))
y = Number.MAX_VALUE;
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
};
jQuery.fn.dataTableExt.oSort['num-html-desc'] = function(a,b) {
var x = a.replace(/[^-.0-9]/g, "");
var y = b.replace(/[^-.0-9]/g, "");
x = parseFloat( x );
y = parseFloat( y );
if (isNaN(x))
x = Number.MIN_VALUE;
if (isNaN(y))
y = Number.MIN_VALUE;
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
};
|
with the following one:
Code: |
jQuery.fn.dataTableExt.oSort['num-html-asc'] = function(a,b) {
var x = a.replace(/,/g,'.').replace(/[^-.0-9]/g, "");
var y = b.replace(/,/g,'.').replace(/[^-.0-9]/g, "");
x = parseFloat( x );
y = parseFloat( y );
if (isNaN(x))
x = Number.MAX_VALUE;
if (isNaN(y))
y = Number.MAX_VALUE;
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
};
jQuery.fn.dataTableExt.oSort['num-html-desc'] = function(a,b) {
var x = a.replace(/,/g,'.').replace(/[^-.0-9]/g, "");
var y = b.replace(/,/g,'.').replace(/[^-.0-9]/g, "");
x = parseFloat( x );
y = parseFloat( y );
if (isNaN(x))
x = Number.MIN_VALUE;
if (isNaN(y))
y = Number.MIN_VALUE;
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
};
|
and clean browser's cache.
Regards,
ARI Soft
|
|
|
|
|
Re:Number sorting problem 8 Years, 2 Months ago
|
Karma: 0
|
Thank you for excellent support. I will try this =)
|
|
|
|
|
|