-
Bug
-
Resolution: Fixed
-
Critical
-
8.0.0, 8.5.2, 8.5.1.2
-
None
-
Security Level: Jimmy
-
None
Steps to Reproduce
1. run the attached example
2. click "doFilter by clear/add"
3. click "doClear by clear/add"
Current Result
no row rendered
Expected Result
render first 50 items
Debug Information
- if you click column C to sort first, then do step 2, 3, this issue doesn't happen.
- if you set <custom-attributes org.zkoss.zul.grid.autoSort="ignore.change"/>, this issue doesn't happen.
- if you call model.sort() before setModel(), this bug doesn't happen. But this can't fulfill user requirement.
Workaround
Grid.java
private static boolean doSort(Grid grid) { Columns cols = grid.getColumns(); if (!grid.isAutosort() || cols == null) return false; for (Iterator it = cols.getChildren().iterator(); it.hasNext();) { final Column hd = (Column) it.next(); String dir = hd.getSortDirection(); if (!"natural".equals(dir)) { return hd.doSort("ascending".equals(dir)); // TODO ZK#5825: change is here to return real doSort value not just true. // return true; } } return false; }
Then, we changed the first case within onListDataChange and introduce an else case if doSort returns false:
private void onListDataChange(ListDataEvent event) { //sort when add int type = event.getType(); if ((type == ListDataEvent.INTERVAL_ADDED || type == ListDataEvent.CONTENTS_CHANGED) && !isIgnoreSortWhenChanged()) { // TODO ZK#5825: negation case is fixing missing call to render if no column is sorted. if (doSort(this)) { getDataLoader().updateModelInfo(); } else { getDataLoader().doListDataChange(event); postOnInitRender(); } } else {