bosskmk / pluto_grid

PlutoGrid is a dataGrid for flutter that can be controlled by the keyboard on desktop and web. Of course, it works well on Android and IOS.
https://pluto.weblaze.dev
MIT License
637 stars 291 forks source link

Wrong ordering of numeric columns [Bug] #954

Closed Acacio2000 closed 7 months ago

Acacio2000 commented 9 months ago

When I click on the title of a numeric column (Number, Currency) using 'locale' numberFormat.symbols.DECIMAL_SEP equal to ',' (comma) the ordering is broken. in example "currency_type_column_screen", try to sort "column 4" or "column 5" ... and see.. sort order fail !

Acacio2000 commented 9 months ago

To get around the problem, I made an adjustment that worked for me. inside pluto_column_type.dart in 'mixin PlutoColumnTypeWithNumberFormat' I adjusted toNumber

// Convert [String] converted to [applyFormat] to [number]. dynamic toNumber(String formatted) { String match = '0-9\-${numberFormat.symbols.DECIMAL_SEP}'; if (numberFormat.symbols.DECIMAL_SEP == ',') { int countP = formatted.split('.').length - 1; int countV = formatted.split(',').length - 1; if ((countV == 0) && (countP == 1)){ match += '.'; } } if (negative) { match += numberFormat.symbols.MINUS_SIGN; } formatted = formatted.replaceAll(RegExp('[^$match]'), '').replaceFirst(numberFormat.symbols.DECIMAL_SEP, '.'); final num formattedNumber = num.tryParse(formatted) ?? 0; return formattedNumber.isFinite ? formattedNumber : 0; }

github-actions[bot] commented 8 months ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 7 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.