11

I have grid column:

{
    header: "",
    sortable: false,
    id: 'value',
    dataIndex: 'value',
    hidden: false,
    editor: {
        xtype: 'textfield',
        allowBlank: false
    }
}

How to escape html entities only in renderer function for this column ?

tallseth
  • 3,635
  • 1
  • 23
  • 24
Bdfy
  • 23,141
  • 55
  • 131
  • 179

3 Answers3

12

The renderer property of a column definition can take either a function or the string name of one of Ext.util.Format's methods. In this case you can use the htmlEncode method by declaring the column as:

{
    header: "",
    sortable: false,
    id: 'value',
    dataIndex: 'value',
    hidden: false,
    editor: {
        xtype: 'textfield',
        allowBlank: false
    },
    renderer: 'htmlEncode'
}
owlness
  • 2,936
  • 18
  • 13
2

There is a autoEncode property on the EditorGridPanel.

"True to automatically HTML encode and decode values pre and post edit (defaults to false)."

Just set it to true.

autoEncode: true
Dasha Salo
  • 5,159
  • 5
  • 26
  • 28
1

hi write this code in app.js file //code for grid xss

Ext.override(Ext.grid.column.Column, {
defaultRenderer: Ext.util.Format.htmlEncode
});
Dinesh P
  • 21
  • 1