java - JavaFX Column sorting for a Column<V, T> where T extends ObservableList<U> -
i have table in i'm displaying email addresses set of clients, such when have 1 email address displays, if there list, states in table cell number of email addresses have, , if have none, displays "none". works fine, have set table cell take care of this. however, column not sort in reasonable order, fair enough, given it's trying sort on list, thought set custom comparator on column thus:
@suppresswarnings({ "rawtypes", "unchecked" }) public static <t extends observablelist<u>, v extends entity, u extends entity> void initializefilteredstringentitylistcolumn( gridcolumn<v, t> column, function<v, t> propertyprovider, function<u, string> stringprovider, string pluralname, listfilterproperty<v> filters) { column.setcellfactory(col -> new stringlisttablecell(stringprovider, pluralname)); column.setcomparator(new comparator<t>() { @override public int compare(t list1, t list2) { u firstitemlist1 = list1.isempty() ? null : list1.get(0); u firstitemlist2 = list2.isempty() ? null : list2.get(0); string listonecomparative = stringprovider.apply(firstitemlist1); string listtwocomparative = stringprovider.apply(firstitemlist2); int compareto = listonecomparative.compareto(listtwocomparative); return compareto; } }); column.setcellvaluefactory(celldata -> { v value = celldata.getvalue(); t t = propertyprovider.apply(value); return (observablevalue<t>) t; }); column.setfiltercontextmenu(searchfiltercontextmenu.contains(filters)); }
when debugging steps compare method, table doesn't seem apply sort order. ideas helpful.
Comments
Post a Comment