0

Instant textbox - cursor moves and input is not accepted

asked 2019-06-25 15:33:13 +0800

cgrill gravatar image cgrill
0

Hi,

I am using version 8.6.0.1. I have a instant textbox with an onChange listener inside the auxheader of a grid. Sometimes, when I change the value of the textbox I am missing the input. Also the cursor is moved one char back unrequested.

<grid height="600px" width="1002px" model="@load(vm.scheduleList.scheduleObjectList)" emptyMessage="No Schedules found"
                            mold="paging" pageSize="11">
                        <auxhead>
                            <auxheader colspan="1">
                                <span sclass="z-icon-filter"/>
                                <textbox instant="true" width="100px" onChange="@command('changeLineFilter', filter=event.value)"/>
                            </auxheader>
                            <auxheader colspan="1">
                                <span sclass="z-icon-filter"/>
                                <textbox instant="true" width="100px" onChange="@command('changeEndFilter', filter=event.value)"/>
                            </auxheader>
                            <auxheader colspan="1">
                                <span sclass="z-icon-filter"/>
                                <textbox instant="true" width="150px" onChange="@command('changeZoneFilter', filter=event.value)"/>
                            </auxheader>
                            <auxheader colspan="3">
                            </auxheader>
                        </auxhead>
                        <columns>
                            <column ...

Here the implementation of the model.

@Command
@NotifyChange("scheduleList")
public void changeLineFilter(@BindingParam("filter") String lineFilter) {
    logger.error("Start changed LineFilter:"+lineFilter);
    scheduleData.setLineFilter(lineFilter);
    logger.error("Finished changed LineFilter:"+lineFilter);
}

@Command
@NotifyChange("scheduleList")
public void changeEndFilter(@BindingParam("filter") String endFilter) {
    logger.error("Start changed EndFilter:"+endFilter);
    scheduleData.setEndFilter(endFilter);
    logger.error("Finished changed EndFilter:"+endFilter);
}

@Command
@NotifyChange("scheduleList")
public void changeZoneFilter(@BindingParam("filter") String zoneFilter) {
    logger.error("Start changed ZoneFilter:"+zoneFilter);
    scheduleData.setZoneFilter(zoneFilter);
    logger.error("Finished changed ZoneFilter:"+zoneFilter);
}

In the output of the logger I see that some chars entered into the textboxes are sometimes not accepted. Sometimes the cursor moves one position back and the input is taken on the wrong position.

Does anyone have the same problem? Is there something how I can fix that?

Best regards,

Christoph

delete flag offensive retag edit

Comments

The issue can be reproduces on the online demo under https://www.zkoss.org/zkdemo/grid/data_filter Enter "12" several times in "Top Nutrients" and sometimes the "2" is not accepted.

cgrill ( 2019-06-25 16:19:38 +0800 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2019-06-26 10:54:29 +0800

cor3000 gravatar image cor3000
4596 2 7
ZK Team

updated 2019-06-26 10:55:58 +0800

This is the default behavior in grid, and listbox, if the model is replaced @NotifyChange("scheduleList") and more than 10 items change the whole grid, listbox is invalidated and re-rendered, including the headers and potentially included filter text boxes.

https://github.com/zkoss/zk/blob/v8.6.0.1/zul/src/org/zkoss/zul/Grid.java#L768

You can override the default invalidation threshold by setting the library property org.zkoss.zul.invalidateThreshold or custom-attribute.

e.g. in your zul:

<grid ...>
  <custom-attributes org.zkoss.zul.invalidateThreshold="1000"/>
  ..
</grid>

Since replacing the rows one by one might be slower, please also observe the potential performance impact to your application.

Also please consider using a ListModelList and replace the contents in the model instead of replacing the whole model for each change. This is especially beneficial, in case only a few elements are added or removed.

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
1 follower

RSS

Stats

Asked: 2019-06-25 15:33:13 +0800

Seen: 5 times

Last updated: Jun 26

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