0

how to truncate too long text in alistcell

asked 2007-02-09 15:14:01 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4149161

By: yennor

Hi

I have a listbox with several columns.
What I want is, that if a text is a listcell is wider then the Column the text should be truncated, so that it perfectly fits in the column. (Perfect would be, if at the end of the text tree points "..." would be displayed, for example:
"this is a long t...").
I've tried it out with

<listcell style="white-space:nowrap;overflow:hidden" label="bla bla bal blab alb abla"/>


But unfortunately it's not working. The columns are automatically resized so that the text perfectly fits, and it's not possible to make them smaller.

Is there any possibility to achieve that?

thanks

Michael

delete flag offensive retag edit

5 Replies

Sort by » oldest newest

answered 2007-02-10 05:46:36 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4150070

By: jumperchen

Hi Michael,

You can use the setMaxlength method of Lable Object ,for example :

<listcell><label maxlength="3" value="bla bla bal blab alb abla"/></listcell>

Jumper

link publish delete flag offensive edit

answered 2007-02-10 11:57:20 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4150259

By: yennor

Hi Jumper

Thanks for the suggestion,
But like that i have the problem, that i need to know how many characters fit into the column (since the characters don't have the same width each, it's not that easy to calculate).
And the user is able to resize the columns. Then it should also automatically change the length of the labels (without sending a request to the server).
I'm afraid with maxlength only it won't work exactly as i'd need it, or is there a possibility?

Michael

link publish delete flag offensive edit

answered 2007-02-13 08:41:32 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4155362

By: henrichen

I am afraid that maxlength is the current solution in town.

/henri

link publish delete flag offensive edit

answered 2014-01-17 12:25:43 +0800

pymsoft gravatar image pymsoft
133 5

I know this is an old post but I have not seen other solutions and I had to fix it.

Example of code:

in itemrenderer

.. ...

public class MyItemRenderer implements ListitemRenderer {

    public void render(Listitem li, Object data, int index) {


        Object[] record = (Object[])data;

        new Listcell("My short text").setParent(li);

        Listcell cTesto = new Listcell("my long long text");
        cTesto.setStyle("white-space:nowrap;overflow:hidden");
        cTesto.setParent(li);

... ..

Best regards

Pedro Gonzalez

link publish delete flag offensive edit

answered 2018-10-23 16:17:44 +0800

phannhuson gravatar image phannhuson
1

Maybe someone have problem with longword (Example: verylonglonglonglongword) in listcell (file *.zul). You can try with style="word-wrap:break-word". It worked in label {<row> <label value="Giá trị" style="font-weight:bold"/> <label style="word-wrap:break-word" id="lbGt"/> </row>}

link publish delete flag offensive edit
Your reply
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: 2007-02-09 15:14:01 +0800

Seen: 220 times

Last updated: Oct 23

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