rendering left arrow as literal in dhtmlxgrid sub_row

Hi - The data I pass into a dhtmlxgrid may include < as a literal (i.e. <). For example, I may want to pass the string:

If x<b then j=4

The text will be processed by the htmlspecialchacters function in php before it is passed into the xml document feeding the grid, so all the special html characters are converted to character entities before being passed into the grid.

This text will be displayed in a sub_row in the grid. The problem is that the sub_row seems to interpret the <b in my sample above as being actual html rather than just text, and it truncates all of the string after the left arrow.

Is there a way to disable html rendering for a sub_row so that it displays the actual text:

if x<b then j=4

in the sub_row, or even better, is there a way to escape part of the string so that the sub_row still renders html, but the text that should be literal is marked so that it is processed as literal. In other words, I want to pass the following to the sub_row:

if x<b then j=4

and have it display if x<b the j=4 inside a table in the sub_row.

Thanks,
Michael

You should replace “<” with “<”

<table border="1"><tr><td>if x<b then j=4</td></tr></table>

If you will pass sub_row content with main grid xml, you should include sub_row cell value into CDATA.

Still no luck. I tried loading both samples xml files below into a grid and neither display properly. The first column is meant for the sub_row. I use the code below to load the xml.
Thanks, Michael

 

XML Sample 1

<?xml version="1.0" encoding="UTF-8" ?>
  • Th text1^index.php^_self text2^index.php^_self text3^index.php^_self Th<is is a p^index.php^_self text4

XML Sample 2

<?xml version="1.0" encoding="UTF-8" ?>
  • ]]> text1^index.php^_self text2^index.php^_self text3^index.php^_self Th<is is a p^index.php^_self text4

I also tried using your sample xml (see below, taken from dhtmlx.com/docs/products/docsExp … lGrid.html) and the content in the CData didn’t load into the subrow.

Thanks Michael

<?xml version="1.0" ?>

top xml tag, mandatory
each row must have unique ID
first column data
second column data


<![CDATA[ ]]>
second column data


<input type=‘button’ value=‘any’ />
second column data

As for above XML, correct one will be

<?xml version="1.0" encoding="UTF-8" ?> <rows> <row id="776"> <cell><![CDATA[Th&lt;is is a p&gt;]]></cell> <cell title="Click here to edit this">text1^index.php^_self</cell> <cell title="Click here to edit this">text2^index.php^_self</cell> <cell title="Click here to edit this">text3^index.php^_self</cell> <cell title="Click here to edit this">Th&lt;is is a p^index.php^_self</cell> <cell>text4</cell> </row> </rows>

CDATA section preserves content as is, and > and < are necessary, because content of sub row is processed as HTML

Whenever I add the CDATA tags I have the same behavior - no sub row appears, and the text that should be there does not appear in the source for the page. This is true regardless of whether there is any HTML inside the CDATA tags.

Do I need to add any additional javascript or set any specific settings to allow the grid to process CDATA properly?

I am testing in FF.

Example that works (no CDATA):

<?xml version="1.0" encoding="UTF-8" ?> This is not a cdata text1^index.php^_self text2^index.php^_self text3^index.php^_self inTh<is is a p^index.php^_self text4

Example that does not work (with CDATA):

<?xml version="1.0" encoding="UTF-8" ?> text1^index.php^_self text2^index.php^_self text3^index.php^_self inTh<is is a p^index.php^_self text4

Whenever I add the CDATA tags I have the same behavior - no sub row appears

There is no need for any extra commands.
But be sure that there is no any whitespaces between cell tag and <![CDATA[

Will work

Will not work

I double checked and there is no whitespace between the cell tag and the CDATA tag. Can you post a working example of javascript that loads an xml document with CDATA loaded into a subrow? I can’t get this to work.

Thanks,
Michael

Sample was sent by PM

Thank you Stanislav - - I think I am beginning to understand the problem.

I think the issue is an interaction between the sub-row and a Firefox patch I got from DHTMLX to resolve a separate issue. Whenever I apply the javascript patch as an include I get the error with the subrow. If I do not include the patch, the subrow works fine. The thing is I need both things to work at once - large fields in Firefox and the CDATA subrow. I am not sure exactly what it is that the subrow doesn’t like about the patch.

The javascript patch (with background) can be found at on this dhtmlx forum thread: viewtopic.php?f=2&t=13525

Thanks,
Michael

Updated patch is attached, it will work correctly for CDATA sections as well.
patch_cdata.zip (763 Bytes)

Is there any way to get around this issue?

Thanks,

Michael

I think the issue is an interaction between the sub-row and a Firefox patch I got from DHTMLX to resolve a separate issue. Whenever I apply the javascript patch as an include I get the error with the subrow. If I do not include the patch, the subrow works fine. The thing is I need both things to work at once - large fields in Firefox and the CDATA subrow. I am not sure exactly what it is that the subrow doesn’t like about the patch.

The javascript patch (with background) can be found at on this dhtmlx forum thread: viewtopic.php?f=2&t=13525

Thanks,
Michael

What about updated patch ? ( above post )
In local samples it allows to process cdata correctly and allows long text node usage in the same time

Hi - any luck determining why there is an interaction between the patch I was sent and this functionality?

Thanks,
Michael

The original one was created to get values from all text nodes, but in FF, CDATA is not a text node, it is a special node type. Updated patch collect values from both text and CDATA sections so must work correctly in all use-cases.

Thanks Stanislav. I will look at and test the updated patch. For some reason it wasn’t showing up in the thread even though I was logged in. I see it now and will play with it.

Thanks

Michael

Thanks Stanislav, the patch fixed both problems!

-Michael