EasyUI Forum

General Category => Bug Report => Topic started by: TSDani on January 21, 2016, 06:41:44 AM



Title: Html escaping chars in Treegrid
Post by: TSDani on January 21, 2016, 06:41:44 AM
Hi,

I have noticed that when you load data or even when you edit a cell data of a string typed column in a TreeGrid,
with this text "</" or any other text that starts with this char '<', leaves the cell empty!

If you inspect the cell in the html source in your web browser, you can see that the data of this cell is in a comment
<!-- </ -->

Any suggestion or idea how to solve this issue?

Thanks in advance.


Title: Re: Html escaping chars in Treegrid
Post by: jarry on January 21, 2016, 08:10:33 AM
You need to escape the inputed characters after editing a row. The code below shows how to achieve this functionality.
Code:
$('#tg').treegrid({
onEndEdit: function(row){
row.name = row.name.replace(/</g,'&lt;');
row.name = row.name.replace(/>/g,'&gt;');
}
})


Title: Re: Html escaping chars in Treegrid
Post by: TSDani on January 21, 2016, 08:25:34 AM
Ok, that only covers the editing part.
What about loading data?
It means that I will need to scan my entire data on the way in and out of the treegrid for these chars?
(I need to return to the server "<" and not "&lt;")

I thought maybe column formatters can solve that.

thanks,


Title: Re: Html escaping chars in Treegrid
Post by: jarry on January 21, 2016, 03:28:03 PM
You also can use the loadFilter function that allows you to convert the original dataset to treegrid rows.