0

Scrollbar in Listbox moves to last selected item

asked 时时彩欢乐生肖走势贵州快3最牛走势图贵州快3形态走势图一定牛金价冲破1530美元创6年新高 黄金基金现在还能不能买

發布時間︰

“的確不是這麼回事,封?開克斯法爾伐先生,我向您發誓??對我來时时彩欢乐生肖走势 我被這個場面弄得心情激動,回家路上,我果決地對自己說︰“挺住! 堅持住!”一定要堅持住!你已經答應過康多爾,你的諾言可要算數。千萬 不要一時神經激動或者脾氣發作而迷失方向!始終要清醒地意識到,這種敵 意實際上只是一個人的絕望心情,這個人愛你,你因為狠心冷酷而有負于她。 堅持到最後一小時——現在一共不過三天半時間。三天一過,你就經受了這 個考驗,你就可以卸去負擔,一身輕松,一連幾個星期,幾個月之久!現在 耐著性子,忍耐些——只有這最後一程,這最後的三天半,這最後的三天! 康多爾的感覺很對。只有那些無法估量、把握不住的東西才嚇唬住我們。 相反,一切有限的東西,一切確定的東西刺激人們去試驗,變成衡量我們力 量的尺度。三天——我覺得,這我是干得了的,意識到這一點,我心里就踏 實了。第二天我值勤于得十分出色,這點可以說明很多問題,因為這一次我 們得比平時早一小時到練兵場上拼命地來回操練,直到汗水流進我們的領 子。使我自己也感到意外的是,我甚至使那位怒氣沖沖的上校也不由自主地 脫口說了句︰“這還不錯。”結果這一次狂風暴雨就更加凶猛地落在施泰因 許貝伯爵的頭上。伯爵是個狂熱的駿馬迷,前天剛弄到一匹新的高腿的紅鬃 烈馬,一匹年輕的、難以馴服的純種馬。可惜他自恃騎術高明,如此輕率不 慎,竟事先沒有好好地試馬。正在布置操練的時候,一只飛鳥的影子把這匹 狡猾的馬給驚了,它就瘋狂地揚起了前蹄;第二次是在進攻的時候,它干脆 狂奔亂竄。倘若施泰因許貝不是一個如此出色的騎手,全線官兵將會看見他 姿勢新奇地從馬上直栽下來。經過一場類似雜技般驚險的搏斗他才把這匹揚 蹄奮鬃的驚馬制服,然而他的這個值得稱道的成績並沒有使他從上校嘴里听 到什麼使人愉快的贊揚。上校惡狠狠地咕嚕道,他永遠禁止在演兵場上表演 馬戲團里的雜耍。倘若伯爵先生對戰馬一竅不通,他至少應該事先在馴馬場贵州快3最牛走势图 我情不自禁地又往後退了幾步。在他說出“謀殺”這兩個字的那一剎那, 我像閃電似的在幻黨中看到了一切,塔樓露台上的欄桿,她正用兩只手死命 地抓住欄桿!我不得不抓住她,並且在最後一刻用力把她拉回來!我知道, 康多爾並沒有言過其實,她正好會這樣做的,她會從那里縱身跳下去的—— 我看見塔樓底下鋪著的方石板就在眼前,這一瞬間我什麼都看見了,仿佛這 一切都是剛剛發生,仿佛這一切已經發生,我的耳朵嗡嗡直響,就仿佛是我 自己從那五六層樓高的塔上飛快地跌了下去。 地把一個人捆注了,直到地老天荒。可是現在已經後退無路。我的同情又一 次比我的意志更強。我把我自己交出去了。我再也不屬于我自己了。贵州快3形态走势图一定牛 對嗎?” 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