Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataTable: frozenColumns + draggableColumns + rendered content gets out of sync #11023

Closed
wlhUser opened this issue Nov 23, 2023 · 8 comments · Fixed by #11237
Closed

DataTable: frozenColumns + draggableColumns + rendered content gets out of sync #11023

wlhUser opened this issue Nov 23, 2023 · 8 comments · Fixed by #11237
Assignees
Labels
🐞 defect Bug...Something isn't working
Milestone

Comments

@wlhUser
Copy link

wlhUser commented Nov 23, 2023

Describe the bug

In DataTable with frozenColumns, draggableColumns and not rendered columns (rendered="false"), table header and content of table gets out of sync. Content is shifted 1 or 2 cols compared to header. This does not happen immediately when displaying the page, but after the 1st ajax update.

Example with 2 Data tables. The 1st has no not rendered columns while the 2nd has one. Otherwise the tables are identical.

Initial page:
InitialPage

Now scroll down in both tables about 30%, and press the 'Update' button.
The 1st table is still ok, while in the 2nd header and data are no longer in sync.
PageAfterUpdate

Reproducer

pf-11023.zip

Expected behavior

No response

PrimeFaces edition

Elite

PrimeFaces version

12.0.6

Theme

No response

JSF implementation

Mojarra

JSF version

4.0.4 (Wildfly30)

Java version

17

Browser(s)

All

@wlhUser wlhUser added ‼️ needs-triage Issue needs triaging 🐞 defect Bug...Something isn't working labels Nov 23, 2023
@melloware

This comment was marked as outdated.

@melloware melloware removed the ‼️ needs-triage Issue needs triaging label Nov 23, 2023
@melloware

This comment was marked as outdated.

@wlhUser
Copy link
Author

wlhUser commented Nov 24, 2023

@melloware to be honest, I do not fully understand the other ticket. I think the problem described in that ticket are related to dragging columns. In my case the problem happens without any dragging. The workaround I use in general is to reduce the frozen columns to 1 or prevent using 'rendered="false"' with columns.

I also tried debugging into the PF Code, but I'm not that deep into it to propose solutions. I could see the in the DataTable Object, all columns are present, independently of being rendered or not, which is OK. But at some point the ordering of the columns gets confused. When debugging in ColumnAware.collectCollumns(), and set a breakpoint in columns.sort(c1, c2), you can see that columns which are not rendered have a displayPriority of 0, which causes them to be shifted to the top of the column list, and in the frozen area.

@melloware
Copy link
Member

I wonder if columns that are NOT rendered should get a priority of 999?

@wlhUser
Copy link
Author

wlhUser commented Nov 24, 2023

I'm not sure if the priority of NOT rendered columns should be changed, as there might be actions which changes their 'render' attribute, and than they might be shifted to a position which is not desired.
But maybe the columns.sort() function could shift them to the end of the columns list, without affecting their prio. However, this is only a rough guess. I did not have the chance to test this approach yet.

@melloware
Copy link
Member

Runnable reproducer with mvn clean jetty:run:
pf-11023.zip

@melloware
Copy link
Member

melloware commented Nov 27, 2023

@wlhUser its not Draggable Columns that is the issue... its virtualScroll="true"

@melloware melloware changed the title DataTable: frozenColumns + draggableColumns - header and data content gets out of sync DataTable: frozenColumns + virtualScrolling- header and data content gets out of sync Nov 27, 2023
@melloware
Copy link
Member

Column order on first render:

form:testTable3_frozenThead Start:= 0 End:= 2
Col1
Col2
form:testTable3_scrollableThead Start:= 2 End:= 5
Col3
Col4
Col5

Column Order on Update:

form:testTable3_frozenThead Start:= 0 End:= 2
Col1
Col4
form:testTable3_scrollableThead Start:= 2 End:= 5
Col2
Col3
Col5

Notice Column4 is 2nd that is because in UITable.decodeColumnDisplayOrderState it is setting them all to 0 then decoding the UI columns.

Map<String, ColumnMeta> columMeta = getColumnMeta();
columMeta.values().forEach(s -> s.setDisplayPriority(0));

However on first update with draggable columns it only sends the 4 visible columns from the client to decode column order which puts the order wrong which puts FrozenColumns=2 now incorrect.

{
	"form:testTable3_columnOrder": "form:testTable3:j_idt10,form:testTable3:j_idt12,form:testTable3:j_idt14,form:testTable3:j_idt18",
	"javax.faces.ViewState": "-7232794966269752203:-2061201527638343433"
}

@melloware melloware changed the title DataTable: frozenColumns + virtualScrolling- header and data content gets out of sync DataTable: frozenColumns + draggableColunms + rendered content gets out of sync Jan 4, 2024
melloware added a commit to melloware/primefaces that referenced this issue Jan 4, 2024
@melloware melloware self-assigned this Jan 4, 2024
@melloware melloware added this to the 13.0.5 milestone Jan 4, 2024
melloware added a commit to melloware/primefaces that referenced this issue Jan 4, 2024
@melloware melloware changed the title DataTable: frozenColumns + draggableColunms + rendered content gets out of sync DataTable: frozenColumns + draggableColumns + rendered content gets out of sync Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 defect Bug...Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants