Search code examples
jquerymodel-view-controllerdevextreme

jquery changes quotation mark to &quot after string injection in MVC


I'm making some tooltip customization of DevExtreeme chart and I want to inject the string into js code in MVC project:

.Tooltip(t => t
    .Enabled(true)
    .Location(Model.Tooltip.Location)
    .CustomizeTooltip(@<text>
function(arg) {
return {
text: @Model.Tooltip.Text 
};
}
    </text>)
)

The string looks like this:

Text = "arg.seriesName + \" years: \" + arg.valueText"

but on the output it is:

text: arg.seriesName +&quot; years: &quot; + arg.valueText 

How to fix that? (& didn't help)

Thanks for your help


Solution

  • I have all the information which define the chart in the model. Here is the solution how it should be implemented:

    Tooltip = new TooltipDataPackage
                {
                    Enabled = true,
                    Location = ChartTooltipLocation.Edge,
                    Text = (item) =>
                    {
                        var func = "function(arg) {";
                        func += "return {";
                        func += "text: arg.seriesName + \" wiek: \" + arg.valueText";
                        func += "};";
                        func += "}";
                        return MvcHtmlString.Create(func);
                    }
                },
    

    The object TooltipDataPackage code is defined as follows:

    public class TooltipDataPackage
    {
        public bool Enabled { get; set; }
        public RazorBlock Text { get; set; }
        public ChartTooltipLocation Location { get; set; }
    
    
    }