HELP! The Dreaded & Ampersand!

I thought we resolved all of the issues with special characters and grids, but alas… they still persist :frowning:

I have a grid with a cell of type: ‘ed’ (I have also tried ‘edtxt’)

When I set this cell contents to something like: “me & marley”, it appears correctly in the cell.

However, when editing the contents of the cell, the user sees: “me & marley”

After exiting “edit” mode, it properly goes back to “me & marley”

How do i prevent this un-user-friendly behavior??

(PS - of course same thing happens with all special characters like <, >, etc)

Surely there must be an answer to this seemingly simple issue!!! :blush:

Hello? Is anyone out there? I need an answer on this…!

Solution is to use ‘edtxt’ type cell and when sending grid data via XML, enclose data in CDATA

Thank you for posting your solution. Helped a lot!!

… a further expansion of this topic.

The use of edtxt to handle ampersands works well for inline editing in a grid.

I now need to cater for inline editing nodes in a tree which contain ampersands.
The only colType I’m aware of for a tree is ‘tree’. However, when I inline edit a node in the tree and include an ampersand, it sends an encoded version of the node value.
So if I type in ‘abc&’, it sends ‘abc&’ to the datapacessor.

Anyone have an answer to this issue?

Unfortunately in case of using the “tree” the text “unescaping” is not supported.

Here’s what works for me…

**Inline editing where tree is connected to a DataProcessor
In the tree object’s onEditCell event, at stage 1, decode first

iTree.attachEvent("onEditCell", function(stage, rId, cInd, nValue, oValue) {
	if(stage == 0) {
		...
		return true
	}else if(stage == 1 && this.editor && this.editor.obj) {
		this.editor.obj.value = myDecode(this.editor.obj.value);		//<= decode all &amp;,&gt;,&lt;,etc to &,>,< etc.
		this.editor.obj.select();
		return true;
	}else if(stage == 2) {
		...
		return true;
	}
});

In the ajax broker script referenced by the DP (e.g. C#)

...
	if (action == "updated") {
		string o_Node = context.Request["o_Node"];
		data = "<updated o_Node=\"" +myHtmlEncode(o_Node)+ "\" />";	// If you need to send data back, encode it
		//call the update script sending the decoded o_Node
		//return some xml including the above data string
	}
...

**Editing the contents of a tree cell via your own custom dialog/form (e.g. dhtmlxForm)
When setting the form’s object’s hidden/input values, decode first

...
	fmForm.setItemValue("action", "update");
	...
	fmForm.setItemValue("f_Node", myDecode(sTree.cells(sTree.getSelectedId(),NodeCellIndex).getValue()));	//<= decode all &amp;,&gt;,&lt;,etc to &,>,< etc.
...

In the ajax broker script referenced by the form (e.g. C#)

...
	if (action == "update") {
		string o_Node = context.Request["f_Node"];
		data = "<updated o_Node=\"" +myHtmlEncode(o_Node)+ "\" />";	// If you need to send data back, encode it
		//call the update script sending the decoded o_Node
		//return some xml including the above data string
	}
...

Hope this is useful to someone.
Mark