Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted on Nov 20, 2008 06:36
open dhtmlx forum
dhtmlxGrid:Setting column headers

What do I need to do, for handling special char when setting column headers.
I have the following string
header_val = "<div style='color:red;' title='#{label}'> *#{truncated_label}</div>"
mygrid_#{group.id}.setHeader("#{header_val}");

How can I handle, new line char in tooltip. In above code, if there is a new line char in title text, I get javasript error.

If I set headers from XML (with attributes like align, width,sort...), can I use cdata? How would xml look with style, title, sort,type, width, align attributes and using cdata for text and title?

Thanks in advance!
Answer posted by Support on Nov 20, 2008 06:53
>>How can I handle, new line char in tooltip.
Most browser will ignore new lines in tooltip. 

>>, if there is a new line char in title text, I get javasript error.
You need to replace them with \n
     header_val = "<div style='color:red;' title='#{label.gsub(/\n/,'\n')}'>
or output it through HTML
<textarea id='header' style='display:none'>#{label}</textarea>
....
header_val = "<div style='color:red;' title='"+document.getElementById("header").value+"'> *

>>If I set headers from XML (with attributes like align, width,sort...), can I use cdata?
Yes
<column sort="str" width="100" align="left"><![CDATA[
   any html content, with new lines or any tags here
]]></column>

http://dhtmlx.com/docs/products/docsExplorer/doc/dhtmlxxml/index.html#dhtmlx_xml