cloudflarearchive / backgrid

Finally, an easily stylable semantic HTML data grid widget with a Javascript API that doesn't suck.
http://backgridjs.com
MIT License
2.01k stars 325 forks source link

[Feature Request] Expose comparator per column. sortValue does not work for special cases. #674

Open ntodorov opened 6 years ago

ntodorov commented 6 years ago

sortValue is a great helper, but not enogh in my case. Please see https://jsfiddle.net/ntodorov/3zaw3hdr/ The gist of it - if you have a column with values like paragraph numbers:

var numbers = [{pn: "2.10"}, 
  {pn: "66.9.90008.56.5"}, 
  {pn: "1.1"},
  {pn: "1.2"},
  {pn: "1.12"},
  {pn: "2.10.1"},
  {pn: "2.10.4"},
  {pn: "0"}];

just giving formated option does not cut it. Better to say I do not see it working with different dot levels that need to be compared. One could have 0 dots the other 5, meaning the comparator needs to compare level by level.

In my jsfiddle the issue is visible and my comparator there sorts perfectly, but I cannot attach it to the column. If you click on the title, it ignores the custom comparator of the collection and creates internal that sorts as a string and that's not the desired order.

Is it possible to expose a property for comparator?

Thanks, Nik