|
Title: Escape Special HTML characters in Datagrid [Solved] Post by: Darrel on April 06, 2016, 03:16:44 AM Hello,
I have the following JSON code for populating the column headers in the datagrid. Code: {"field":"col_0","title":"Column 0","formatter":"createLink","sortable":"true","width":"25%","align":"left","halign":"center"},I have the following JSON code for populating the rows in the datagrid. Code: {"total":1,"rows":[{The above code gets returned when I invoke the url property of the datagrid, as follows: Code: function createLink(value,row,extra) As you can see in the above block col_1, col_2, col_3 and col_4 have a html string as their data. The code works fine, however on clicking those column elements, the alert message is displayed. I want the datagrid to escape html string if they are coded in the json directly. If the formatter option of the datagrid is used, then only that column in the grid should be rendered as a html element, but the other columns should displayed plain text only. Is it possible to escape the strings that are returned as a JSON object to create the datagrid on some event in the datagrid like onLoadSuccess or something??? Please note: I don't want the html to get escaped while getting the response from the ajax call. I want it to get escaped while populating it in the grid. Thanks and Regards, Darrel Title: Re: Escape Special HTML characters in Datagrid Post by: stworthy on April 06, 2016, 07:32:51 PM The 'loadFilter' function can be used to transorm the data before loading into the datagrid.
Code: $('#dg').datagrid({Title: Re: Escape Special HTML characters in Datagrid Post by: Darrel on April 06, 2016, 08:22:48 PM Hello stworthy,
I did the following and it worked as expected: Code: function formatData(data) The idea for using that loadFilter function is simply amazing!!!! Thanks a lot for your response :) God Bless!!!!!! Regards, Darrel. |