PHP Classes

Cannot use ampersand in cell text?

Recommend this page to a friend!

      DrasticTools  >  All threads  >  Cannot use ampersand in cell text?  >  (Un) Subscribe thread alerts  
Subject:Cannot use ampersand in cell text?
Summary:All text after the "&" symbol lost
Messages:7
Author:Nathan Elliott
Date:2008-12-15 19:58:55
Update:2008-12-29 20:47:37
 

  1. Cannot use ampersand in cell text?   Reply   Report abuse  
Picture of Nathan Elliott Nathan Elliott - 2008-12-15 19:58:56
I used to be able to use the "&" in cell text with an older version of drastic tools. (Version 0.6.10 I believe). I upgraded to 0.6.13 and found that entering the text: "A&E" results in only "A" being added to the database.

Is this a bug or user error?

Thanks

  2. Re: Cannot use ampersand in cell text?   Reply   Report abuse  
Picture of dd dd - 2008-12-16 11:38:03 - In reply to message 1 from Nathan Elliott
It's a bug and it is already on the bug list.
If there is enough time to issue a new version (and maybe donations) then it will be included.

  3. Re: Cannot use ampersand in cell text?   Reply   Report abuse  
Picture of Nathan Elliott Nathan Elliott - 2008-12-16 20:22:01 - In reply to message 2 from dd
I found one way to fix this problem... it may break something else, but initial testing with my data set, I do not see any problems.

I changed the file: DrasticTools/js/drasticGrid.js, line 289

original:

var url = t.options.path+'?op=u&id='+obj.ddsqlid+'&col='+colname+'&value='+encodeURI(value)+t.options.addparams;

to:

var url = t.options.path+'?op=u&id='+obj.ddsqlid+'&col='+colname+'&value='+encodeURIComponent(value)+t.options.addparams;

Reverting to "escape(value)" also appears to work here, but after reading this site:

xkr.us/articles/javascript/encode-c ...

I decided to go with encodeURIComponent(value).

Thanks

  4. Re: Cannot use ampersand in cell text?   Reply   Report abuse  
Picture of Nathan Elliott Nathan Elliott - 2008-12-17 00:50:54 - In reply to message 3 from Nathan Elliott
Update to my previous message: The above change is still working for me under Firefox, but not on Safari or Chrome. It mostly works on Opera, but I observed some funny behavior with cells appearing blank on initial load.

On a related note, I can't get this latest version of drasticGrid to work at all under IE, but ... I also don't care? LOL

  5. Re: Cannot use ampersand in cell text?   Reply   Report abuse  
Picture of dd dd - 2008-12-27 23:00:05 - In reply to message 4 from Nathan Elliott
Hi Nathan,

You are right: 'encodeURIComponent' is the right function to use there and it will be replaced in the coming version of drastictools.
It should work in all common browsers including IE, but not in Safari.

regards, drasticdata

  6. Re: Cannot use ampersand in cell text?   Reply   Report abuse  
Picture of Nathan Elliott Nathan Elliott - 2008-12-29 17:54:33 - In reply to message 5 from dd
I fooled around with this a little more this past week:

"encodeURIComponent" results in the following behavior:

Text: "A&B" - Cell data updates MySQL properly in all tested browsers.
Cell data is displayed only as "A" in DrasticGrid on IE, Chrome and Safari.
Cell data is not displayed at all in Opera unless I scroll to page 2, then back to page 1.

Text: "A&B C" - Works fine in all browsers.

Weird.

Tested with -

Firefox 3.05
Opera 9.63
IE 7.0 (5730.11)
Chrome 1.0.154.36
Safari 3.2.1 (525.27.1)

P.S. - My IE problem was due to leaving a comma off the end of one of the DrasticGrid column name/width definition lines. This prevented the grid from loading at all in IE.

  7. Re: Cannot use ampersand in cell text?   Reply   Report abuse  
Picture of dd dd - 2008-12-29 20:47:38 - In reply to message 6 from Nathan Elliott
Hi Nathan,

Very wierd indeed. I just did some small test and it appears that the problem is not in the change to the database any more, but the displaying of the contents of the database in the different browsers. In other words, the text "A&B" is stored in the database correctly but not displayed right in IE etc.
I fixed it but it contains multiple changes, so I will include it in the coming release. If you need it earlier, I could send the changed file to you in advance. Then send me a message on [email protected]

best regards, drasticdata