PDA

View Full Version : [CLOSED]GridView cell data html entities



Jack Allegrezza
10 Jul 2010, 12:59 PM
If you amke an xhtml doc then when GridView make the html for the table and tries to insert it to the body div it gets a js exception (only if xhtml) and some cell data contains html entities - the cell data needs to be escaped - it looks like it should be done in the cellTemplate as the template is making the hmtl from strings and data so it should escape?
any way here is a quick fix I did in GridView.doRender to make it work it works but is not the correct solution


for (var i = 0; i < colCount; i++) {
column = columns[i];

meta.id = column.id;
meta.css = i === 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : '');
meta.attr = meta.cellAttr = '';
meta.style = column.style;
meta.value = column.renderer.call(column.scope, record.data[column.name], meta, record, rowIndex, i, store);

meta.value = meta.value.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');

if (Ext.isEmpty(meta.value)) {
meta.value = '&#160;';
}

if (this.markDirty && record.dirty && Ext.isDefined(record.modified[column.name])) {
meta.css += ' x-grid3-dirty-cell';
}

colBuffer[colBuffer.length] = cellTemplate.apply(meta);
}

Condor
11 Jul 2010, 12:03 PM
You are responsible for your own data in the grid. If you know that a column contains non-HTML text then you should configure it with renderer:'htmlEncode'.

evant
11 Jul 2010, 3:33 PM
Agreed, it's not really worth the overhead to do it automatically.