-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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.
i have a few columns, and one of the columns is made to be editable if the row is selected
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.
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:
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?
Hi, yes I'll try to explain this a little bit better. We are currently running ZK 9.6.0.1.
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);
}
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.
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.
If you de-select a checkmark, the checkmark stays de-selected on the first click.
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
...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.
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.
Asked: 2024-01-26 20:45:26 +0800
Seen: 7 times
Last updated: Feb 17