PDA

View Full Version : Special character handling in YUI-Ext



rahulmca1@gmail.com
5 Jun 2007, 10:35 PM
Hi,

I am using array grid to display records from server database.

Problem is if I am and field of record has '<' character like 'hello<friends'
then this field is shown truncated and shown as 'hello' in the grid.

This is because when rendering '<' is recognized as starting of html tag.

So we need to replace it with &lt; then values are rendered correctly as 'hello<friends'.

On server side I replaced illegal characters like '<' with &lt; eg--'hello&lt;friends'

Now when parsing xml using javascript I get 'hello<friends' I am not getting 'hello&lt;friends'
which is as it should be.

Should I now again replace '<' character in 'hello<friends' by '&lt;' so that data in grid is displayed correctly.

Now How do I go about it.


Thanks
with regards.

rahulmca1@gmail.com
6 Jun 2007, 7:58 AM
Hi,

Still wondering how should I proceed.

Few comments will help.

Have a nice time.

HuyDung
6 Jun 2007, 8:34 AM
As I remember, there are several posts in the forum discuss the similar problem.
You should search the forum harder.

----
Aniwei
use renderer like this:

cm = new Ext.grid.ColumnModel([
{
header: 'name'
,dataIndex: 'username'
,renderer: function(data){
/*the data parameter hold your record data, play with it and generate some HTML */
return /*return some html code*/ ;
}
}
])

You have a string containt some '<', and you need to write a function to change all to '&lt;', it's not hard, right?

-------
have you seen the grid/grid editor screencast???

tryanDLS
6 Jun 2007, 8:41 AM
You could do it in a grid renderer. The other possibility would be to try wrapping the data in xml node in cdata tags to keep it from being parsed. Not sure how this would be treated by javascript.