0

html in a grid

asked 2010-01-28 09:54:42 +0800

AllenFox gravatar image AllenFox
159 4

by default zk grids escape html characters when rendering rows. i need to show the text as it is with formatting, colors, etc. is there any way it can be done?

delete flag offensive retag edit

5 Replies

Sort by ยป oldest newest

answered 2010-01-28 10:31:19 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2010-01-28 10:33:44 +0800

Try this,

		Grid grid = new Grid();
		grid.setWidth("100%");
		grid.setParent( yourParent );

                // Columns container
		Columns columns = new Columns();
		columns.setSizable(true);
		columns.setParent(grid);

                // Column
		Column column1 = new Column();
		column1.setWidth("300px");
		column1.setLabel("Subject");
		column1.setStyle("text-align:right; color:blue;" );
		column1.setParent(columns);
		Column column2 = new Column();
		column2.setWidth("200px");
		column2.setLabel("value");
		column2.setStyle("text-align:center; color:red;" );
		column2.setParent(columns);

                // Rows container
		Rows rows = new Rows();
		rows.setParent(grid);

                // Row
		Row row = new Row();

		Label label_TableName = new Label("Is there anybody out there ?");
		label_TableName.setStyle("text-align:left; color:maroon; font-weight:bold" );
		label_TableName.setParent(row);

		Label label_RecordCount = new Label("hello her i am");
		label_RecordCount.setStyle("text-align:left; color:green; font-weight:bold" );
		label_RecordCount.setParent(row);
		row.setParent(rows);

best
Stephan

link publish delete flag offensive edit

answered 2010-01-29 07:18:25 +0800

AllenFox gravatar image AllenFox
159 4

Hi, Stephan. Thanks for your answer.
Here's what I've got and what I want to get: the text is taken from the database, it is formatted somehow (e.g. <p>here's <span style="color: rgb(255, 0, 0);">a text</span></p>). The text should be passed to zk grid (grid, list, tree, whatever) in such a way that the user will see "here's a text", and "a text" will be red.
I wonder, why the guys from Potix decided to escape html characters by default. From my point of view it's much easier and more convenient not to have the characters being encoded all the time but leave it to the programmer to decide whether to do it or not. It could also be a good solution to have some method like setEscapeHtml(boolean) in order to switch the conversion on or off.

link publish delete flag offensive edit

answered 2010-01-29 07:28:38 +0800

mjablonski gravatar image mjablonski
1284 3 5
http://www.jease.org/

updated 2010-01-29 07:29:03 +0800

Hi,

simply put your content in a Html-Component:

row.appendChild(new Html("<p>your <b>formatted</b> text</p>"));

Cheers, maik

link publish delete flag offensive edit

answered 2010-01-29 08:07:19 +0800

AllenFox gravatar image AllenFox
159 4

updated 2010-01-29 08:07:35 +0800

Thanks, Maik. This is exactly what I was looking for.

link publish delete flag offensive edit

answered 2010-03-23 17:27:07 +0800

Stas283 gravatar image Stas283
93 2
www.trade4stas.com

Thank you, Maik. It helped me too. It would be nice if escapeHTML property was exposed for all HtmlBasedComponent's

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: 2010-01-28 09:54:42 +0800

Seen: 825 times

Last updated: Mar 23 '10

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