jQWidgets Forums

jQuery UI Widgets Forums TreeGrid HTML encoding?

This topic contains 3 replies, has 2 voices, and was last updated by  Peter Stoev 10 years, 10 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • HTML encoding? #56259

    codest
    Participant

    I got the TreeGrid samples to work, but I noticed that cell values are not HTML-encoded. I am using data source in Json format.

    Is there a flag that would trigger HTML-encoding?

    HTML encoding? #56274

    Peter Stoev
    Keymaster

    Hi codest,

    By default, it allows displaying of HTML within the cells. You can override the default rendering by implementing a cellsRenderer callback function. Example: http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxtreegrid/javascript-tree-grid-cells-renderer.htm?arctic

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

    HTML encoding? #56851

    codest
    Participant

    Hi Peter,

    Thank you for the example. Here is a render function I came up with:

    var renderer = function (row, dataField, cellValue, cellText, rowData) {
    // HTML-encode a string
    var encodedValue = $(‘<div/>’).text(cellValue).html();
    return $(cellText).text(encodedValue).prop(‘outerHTML’);
    }

    It works fine, yet I am facing another issue: with the same grid I am allowing users to add or modify rows (using scripts similar to what you have in the examples), and to my surprise, such values already come through as encoded. The custom renderer encodes them again, causing double-encoding.

    HTML encoding? #56858

    Peter Stoev
    Keymaster

    Hi codest,

    The Editor displayed in the widget is HTML Input tag and its value is synchronized with the cell’s value i.e input.value == cell’s value. As far as I know, the input will not display html tags. However, if you want to make some custom things, your options are: Update your data before loading it in the widget – you can use the dataAdapter’s beforeLoadComplete or set up the editor according to your requirements by implementing the createEditor and initEditor callback functions.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.