0

Listbox SelectAll checkbox acts weird

asked 2024-01-26 20:45:26 +0800

AndreiArdei gravatar image AndreiArdei
111 3

updated 2024-01-30 17:11:51 +0800

hawk gravatar image hawk
3205 1 5
http://hawkphoenix.blogsp... ZK Team

Hi, this is a little difficult to explain but i'll do my best.

All code is written in Java, not in ZUL. So I have a listbox which gets a model and a listener. The model just uses the class org.zkoss.zul.ListModelList for everything related to Selection. I need to update the data in certain columns and the moment I do this, ZK seems to make a double selection.

image description

i have a few columns, and one of the columns is made to be editable if the row is selected

image description

I achieve this by an EventListener for changes in code, which then changes the model via setElementAt. This seems to make ZK add the 'checked' class to the checkbox, and then remove only to add it back in a second later. If i remove the call for setElementAt, i cannot reproduce this behaviour anymore.

The problem i have is that this not only happens with each row individually but with the select all checkmark in the header of the listbox. I tried identifying if this is a server side issue, however the value on the server is not changed (from what I last set it to be), therefore i think it's an error in the javascript files of ZK.

If it helps, i can make a video possibly and upload it here / youtube.

delete flag offensive retag edit

3 Answers

Sort by ยป oldest newest most voted
0

answered 2024-01-30 17:23:36 +0800

hawk gravatar image hawk
3205 1 5
http://hawkphoenix.blogsp... ZK Team

I don't understand the problem you described. Do mean when you edit the "applied" column, the row should not selected?

Could you describe the problem in the following format:

  • steps to reproduce
  • current result
  • expected result

Besides, I don't find a method called setElementAt() on any zk component. Which version do you use? Is it probably a custom method made by you?

link publish delete flag offensive edit
0

answered 2024-01-30 18:11:06 +0800

AndreiArdei gravatar image AndreiArdei
111 3

Hi, yes I'll try to explain this a little bit better. We are currently running ZK 9.6.0.1.

getElementAt()

let me explain first the setElementAt. Turns out i made a mistake and it's called getElementAt. We use it to get a reference to the list. We have a model class which extends ListModelList<Object> from ZK. We store data in the form of a java List of objects (to create the impression of a table). The main code to set the value looks as follows:

if (getElementAt(row) instanceof List)
{
        // This method is from org.zkoss.zul.ListModelList.getElementAt(int j)
        vector = (List<Object>) getElementAt(row); 
        vector.set(col, aValue);
}

Steps to reproduce

I will use the images above to explain Have a Listbox with multiple = true. When no row is selected, it looks "uneditable" to the user. When you select a row, certain columns in that row become editable, for a user to change the value. This value is computed when the user selects the row, by listening to the on select and then calling the code to run the above code snippet.

Current behaviour

If you deselect a checkmark, ZK fires only one event (the deselect event) to the server (which we use to hide the editor, make calculations etc). However, on front-end it looks like you de-select the checkmark and you re-select it again, confusing users as to if the row is selected or not. If you click again (on what now looks as a selected checkmark) it fires an event, but the server already is aware that the row is deselected (from the first click). This then fixes the front-end too.

Expected behaviour

If you de-select a checkmark, the checkmark stays de-selected on the first click.

Additional information

If we comment out the part where we set a new value in code, then we cannot reproduce this behaviour on rows. However, we were able to reproduce this without our special code to set values on the "select all" checkmark which is part of the header. In our configuration this one always looks like a double selection

image description

link publish delete flag offensive edit
0

answered 2024-02-17 16:04:35 +0800

hawk gravatar image hawk
3205 1 5
http://hawkphoenix.blogsp... ZK Team

Deselect issue

...If you deselect a checkmark, ..., on front-end it looks like you de-select the checkmark and you re-select it again, ..

You mean:

you deselect an item, it turns to unselected, then becomes selected at the end in a browser

right?

I can reproduce a bug that is similar to what you describe: https://tracker.zkoss.org/browse/ZK-5648

Please confirm it. If that's the bug you saw, you can apply the workaround mentioned in the tracker.

Select all issue

I cannot reproduce it with https://zkfiddle.org/sample/2bs8phl/1-select-all

I think it might be related to your custom ListModelList, you can replace it with a standard one to try. Or it might be related to how you make the columns editable. maybe the way you change the components cause a listbox re-rendering.

Please give related code.

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2024-01-26 20:45:26 +0800

Seen: 6 times

Last updated: Feb 17

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More