0

Scrollbar in Listbox moves to last selected item

asked 快播成人电影网免费成人电影网站免费成人电影网人口超千万GDP过万亿:中国这11个城市做到了

發布時間︰

她眼楮閃著異樣的光輝,把身子伸到欄桿外面,頭往下低,樣子十分危 險。我大驚失色,一躍而起,迅速地一把抓住她的胳臂。可是她渾身一顫, 好像火燒灼了她的皮膚。她對我嚷道︰ 快播成人电影网 嗓子眼里。現在每天都得這樣下去了,每天每夜,信一封接一封,一封又一 封。我要是寫信給她,她又要回信給我。我要是不回信,她會來討回信。她 總向我要點什麼,每天如此,日日如此!她會派人送信給我,打電話給我, 派人刺探我的每一步行蹤,她想要知道,我什麼時候出門,什麼時候回家, 跟誰呆在一起,想知道我的一言一行,一舉一動,我已經看出,我是完了—免费成人电影网站 “不過,親愛的艾迫特小姐——請您別在我身上尋找什麼神秘的動機。 歸根結底,您也相當了解我了,您不會不知道,我這人很少考慮自己的言行。 我向您發誓,我還從來沒有想到過要自我反省一下,為什麼我去看這家,去 看那家,為什麼我喜歡這些人,不喜歡那些人。我以入格擔保——我的確沒 法給您更聰明或者更愚蠢的回答,只能跟您說,我之所以老到府上來看您們, 就是因為我喜歡到府上來,因為我覺得在府上比在任何地方都舒服一百倍。 我想,您們大概過于按照喜歌劇所描寫的樣子來想象我們騎兵的生活方式, 總是風度翩翩,總是快快活活,好像一年到頭都在過節似的。然而,到里頭 去一看,其實並不是那麼富麗堂皇,即便是備受贊揚的伙伴之間的集體精神 有時候也相當靠不住。不論在哪兒,只要十幾個人套在一起拉車,總有一個 拉得比別人起勁,要是輪到升遷晉級,就很容易得罪徘在前頭的那個人。每 說一句話都得小心謹慎。你心里永遠沒有把握,不知自己是否引起了上級軍 官的不快;空氣里不知什麼地方總醞釀著一場暴風雨。在部隊服役也是一種 徭役,服役的人談不上獨立。再說,兵營和酒館也永遠不是什麼正經的家庭 生活。在那里誰也不需要誰,誰的事別人也不在乎。不錯,不錯,有時候伙 伴之間關系也挺熱乎,但是最終的安全感是永遠不能真正得到的。相反,如 果我到你們這兒來,我把佩刀解下,同時也把各式各樣的顧慮困擾都擱置一 邊,然後我和你們心情舒暢地閑聊起來,那麼??” “要是??要是我求您呢???要是我誠心誠意、親切友好地求您 呢?”免费成人电影网 “啊,這沒什麼,”我又開起玩笑來,“不是什麼嚴重的事情。一個淘 氣的孩子把水潑到我身上來了。” 2019-07-29 16:02:29 +0800

anvibb gravatar image anvibb
3 1

Hi, guys! I have some trouble with scrollbar in the Listbox component - when I set the model to it and selecting several listitems, the scrollbar moves down to the last selected item, but I need to keep it on top. We've used simple zul as a view:

<zk>
<window xmlns="http: //www.zkoss.org/2005/zul" xmlns:xsi="http: //www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http: //www.zkoss.org/2005/zul http: //www.zkoss.org/2005/zul/zul.xsd"
        use="com.otr.sufd.zkossforms.table.SetDocColumnsView"
        closable="true" border="normal" title="Customize columns" ctrlKeys="" height="400px" width="300px">
    <borderlayout width="100%" height="100%">
        <center>
            <listbox id="table" checkmark="true" vflex="true" fixedLayout="true" multiple="true" width="100%">
                <listhead>
                    <listheader align="left">Column title</listheader>
                </listhead>
            </listbox>
        </center>

        <south size="36" autoscroll="true">
            <toolbar align="end">
                <button label="OK" id="okButton" height="24px" width="75px" mold="os"/>
                <button label="Reset" id="resetButton" height="24px" width="75px"/>
                <button label="Cancel" id="cancelButton" height="24px" width="75px" mold="os"/>
            </toolbar>
        </south>
    </borderlayout>
</window>

</zk>

In SetDocColumnsView I filled Listbox by model and make some AfterCompose actions:

public void configureView(List<? extends HeaderElement> columns, Set<String> hiddenIds) {
    setSizable(true);

    final ListModelList tableModel = new ListModelList(columns);
    tableModel.setMultiple(true);
    table.setModel(tableModel);
    table.renderAll();
    for (int i = 0; i < columns.size(); i++) {
        final HeaderElement column = columns.get(i);
        if (column != null) {
            final Listitem listitem = table.getItemAtIndex(i);
            listitem.setLabel(column.getLabel());
            final String columnId = column.getId();
            listitem.setValue(columnId);
            listitem.setSelected(!hiddenIds.contains(columnId));
        }
    }
}
@Override
public void afterCompose() {
    table = (Listbox) getFellow("table");
    final Button okButton = (Button) getFellow("okButton");
    //adds some listeners to buttons
    addForward(Events.ON_OK, okButton, Events.ON_CLICK);
    addForward(Events.ON_CANCEL, cancelButton, Events.ON_CLICK);
    okButton.setFocus(true);
}

And then I show the dialog window by this code:

final SetDocColumnsView dialog = UIUtils.loadComponent(SetDocColumnsView.getUrl());
dialog.configureView(columnList, hiddenIds);
dialog.setPage(getPage());
dialog.doHighlighted();

I've tried to use some advice given in other threads, such as:

Clients.scrollIntoView(table.getItemAtIndex(0))

or call JS function inside my configureView method:

Clients.evalJavaScript("zk.Widget.$('" + dialog.table.getUuid() + "')._scrollToIndex(0);")

or keep all listitems what I need to select in a different Set and post to setSelectedItems method of Listbox, but everything is without success. Also, I've tried to debug a JS function _doScroll in Listbox.js but I don't figure out from where it has been called :(

I will be very appreciated if someone can help me with this problem.

Best regards, Roman

delete flag offensive retag edit

Comments

if your example is simple, please paste it into http://zkfiddle.org/ so that anyone can have a look directly, this increases your chances of getting a response quickly

cor3000 ( 2019-07-29 18:30:05 +0800 )edit

Yeah, I made simple zkfiddle example - http://zkfiddle.org/sample/1a44bo/1-scrollbar-in-listbox-moves-to-last-selected-item which reproduces the problem

anvibb ( 2019-07-30 21:16:58 +0800 )edit

4 Answers

0

answered 2019-08-01 09:12:39 +0800

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

Thanks for the zkfiddle example. Remove renderAll() can solve scrolling position issue. Listbox by default will render necessary Listitem for visible range, you don't need to call renderAll() which will enforce rendering all Listitems which is unnecessary for most cases. Please refer to http://zkfiddle.org/sample/1a44bo/2-scrollbar-in-listbox-moves-to-last-selected-item#source-2

link publish delete flag offensive edit
0
link publish delete flag offensive edit
0

answered 2019-07-31 21:05:33 +0800

anvibb gravatar image anvibb
3 1

updated 2019-08-01 09:01:48 +0800

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

Thank you for the response, hawk!

I tried to change the selection of items as you advised, but it doesn't solve my problem - when I select several items via ListModeList.setSelection, the scrollbar moves down to the last item. I made an example of that behavior in zkfiddle - http://zkfiddle.org/sample/1a44bo/1-scrollbar-in-listbox-moves-to-last-selected-item

link publish delete flag offensive edit
0

answered 2019-08-01 17:45:43 +0800

anvibb gravatar image anvibb
3 1

Removing renderAll() is helped!

Thank you so much!

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-07-29 16:02:29 +0800

Seen: 12 times

Last updated: Aug 01

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