-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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?
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
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.
Hi,
simply put your content in a Html-Component:
row.appendChild(new Html("<p>your <b>formatted</b> text</p>"));
Cheers, maik
Thanks, Maik. This is exactly what I was looking for.
Thank you, Maik. It helped me too. It would be nice if escapeHTML property was exposed for all HtmlBasedComponent's
Asked: 2010-01-28 09:54:42 +0800
Seen: 825 times
Last updated: Mar 23 '10