PDA

View Full Version : ListStore dont include in BeforeSort the new sorting



Arno.Nyhm
18 Nov 2009, 6:44 AM
the ListStore dont include in BeforeSort the new sorting in the attached event object :-(



to get the new sorting i would change in ListStore this part:



public void sort(String field, SortDir sortDir) {
if (!fireEvent(BeforeSort, createStoreEvent())) {
return;
}
SortInfo prev = new SortInfo(sortInfo.getSortField(), sortInfo.getSortDir());

if (sortDir == null) {
if (sortInfo.getSortField() != null && !sortInfo.getSortField().equals(field)) {
sortInfo.setSortDir(SortDir.NONE);
}
switch (sortInfo.getSortDir()) {
case ASC:
sortDir = SortDir.DESC;
break;
case DESC:
case NONE:
sortDir = SortDir.ASC;
break;
}

}

sortInfo.setSortField(field);
sortInfo.setSortDir(sortDir);


to this:





protected SortInfo prev = new SortInfo();

[...]

public void sort(String field, SortDir sortDir) {

prev = new SortInfo(sortInfo.getSortField(), sortInfo.getSortDir());

if (sortDir == null) {
if (sortInfo.getSortField() != null && !sortInfo.getSortField().equals(field)) {
sortInfo.setSortDir(SortDir.NONE);
}
switch (sortInfo.getSortDir()) {
case ASC:
sortDir = SortDir.DESC;
break;
case DESC:
case NONE:
sortDir = SortDir.ASC;
break;
}

}

sortInfo.setSortField(field);
sortInfo.setSortDir(sortDir);

if (!fireEvent(BeforeSort, createStoreEvent())) {
sortInfo.setSortField(prev.getSortField());
sortInfo.setSortDir(prev.getSortDir());
return;
}