Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Michael Gordon on Jun 05, 2008 18:06
open dhtmlx forum
Escaping commas

Hey,
I was wondering about escaping commas. It appears to be \\, but when I do something like this:

grid.addRow(2,"Test  <img src='http://www.google.com/intl/en_ALL/images/logo.gif' onclick=\"someFn('hello'\\,'world');\"/>");

My html fails to render.

Is my syntax incorrect? (it doesn't work as \, either)

Thanks so much,
Michael
Answer posted by Support on Jun 06, 2008 01:53
The addRow has alternative syntax, which can be used if you plan to add values with commas
Instead of
    grid.addRow(id,"a,b,c");
you can use
    grid.addRow(id,[a,b,c]) // use an array instead of comma separated string

    grid.addRow(2,["Test  <img src='http://www.google.com/intl/en_ALL/images/logo.gif' onclick=\"someFn('hello','world');\"/>"]);
Answer posted by Michael Gordon on Jun 06, 2008 05:35

What if I want to pass an object?

grid.addRow(2,["Test  <img src='../images/img.gif' onclick=\"someFn(" + grid + " );\"/>"]); 
This throws an error, as does:

var args = {one:1};
grid.addRow(2,["Test  <img src='../images/img.gif' onclick=\"someFn(" + args + " );\"/>"]); 

Thanks for your quick response,
Michael

Answer posted by Support on Jun 06, 2008 06:06
The code which you are using for new row creating will be converted to string in any case, so it not possible to store object references in it.