Я думаю, что this
является сфера контроллера Ext.grid.Panel
(если не указано иное, см редактировать), поэтому он wan't работу с помощью ключевого слова. Во всяком случае, второй является лучшим решением ИМО
Edit:
Как прокомментировал @kevhender scope может быть определена для визуализатора. Но поскольку вы используете один из аргументов, это не имеет смысла. Во всяком случае, я пропустил это.
Edit 2 - почему область по умолчанию Ext.grid.Panel
:
Вот отрезала от функции, которая обработает рендеринга. Метод является приватным и, следовательно, не указан в API. В любом случае вот source link. Обратите внимание, что визуализатор вызывается либо с заданной областью, либо с областью контейнера владельца column.renderer.call(column.scope || me.ownerCt,//...
, владелец представления - это панель, в которую она вложена.
/**
* @private
* Emits the HTML representing a single grid cell into the passed output stream (which is an array of strings).
*
* @param {Ext.grid.column.Column} column The column definition for which to render a cell.
* @param {Number} recordIndex The row index (zero based within the {@link #store}) for which to render the cell.
* @param {Number} columnIndex The column index (zero based) for which to render the cell.
* @param {String[]} out The output stream into which the HTML strings are appended.
*/
renderCell: function(column, record, recordIndex, columnIndex, out) {
//... more code
if (column.renderer && column.renderer.call) {
value = column.renderer.call(column.scope || me.ownerCt, fieldValue, cellValues, record, recordIndex, columnIndex, me.dataSource, me);
if (cellValues.css) {
// This warning attribute is used by the compat layer
// TODO: remove when compat layer becomes deprecated
record.cssWarning = true;
cellValues.tdCls += ' ' + cellValues.css;
delete cellValues.css;
}
}
// ... more code
'this' установлен как функция рендеринга внутри этой функции, используйте« scope »в определении столбца, чтобы определить« this »для рендеринга. – kevhender
Еще один трюк, чтобы сохранить несколько символов. Ваш оператор return может быть 'return value || '' ' – kevhender