Pass row, column and data as context to format

This commit is contained in:
Faris Ansari 2018-03-07 13:40:25 +05:30
parent 7683892142
commit ee0f6e512e
7 changed files with 60 additions and 11 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -1409,6 +1409,17 @@ class DataManager {
};
}
/**
* Returns the original data which was passed
* based on rowIndex
* @param {Number} rowIndex
* @returns Array|Object
* @memberof DataManager
*/
getData(rowIndex) {
return this.data[rowIndex];
}
hasColumn(name) {
return Boolean(this.columns.find(col => col.content === name));
}
@ -2538,7 +2549,9 @@ class CellManager {
if (isHeader || isFilter || !cell.column.format) {
contentHTML = cell.content;
} else {
contentHTML = cell.column.format(cell.content, cell);
const row = this.rowmanager.getRow(cell.rowIndex);
const data = this.datamanager.getData(cell.rowIndex);
contentHTML = cell.column.format(cell.content, row, cell.column, data);
}
if (this.options.enableTreeView && !(isHeader || isFilter) && cell.indent !== undefined) {

View File

@ -1408,6 +1408,17 @@ class DataManager {
};
}
/**
* Returns the original data which was passed
* based on rowIndex
* @param {Number} rowIndex
* @returns Array|Object
* @memberof DataManager
*/
getData(rowIndex) {
return this.data[rowIndex];
}
hasColumn(name) {
return Boolean(this.columns.find(col => col.content === name));
}
@ -2537,7 +2548,9 @@ class CellManager {
if (isHeader || isFilter || !cell.column.format) {
contentHTML = cell.content;
} else {
contentHTML = cell.column.format(cell.content, cell);
const row = this.rowmanager.getRow(cell.rowIndex);
const data = this.datamanager.getData(cell.rowIndex);
contentHTML = cell.column.format(cell.content, row, cell.column, data);
}
if (this.options.enableTreeView && !(isHeader || isFilter) && cell.indent !== undefined) {

View File

@ -1408,6 +1408,17 @@ class DataManager {
};
}
/**
* Returns the original data which was passed
* based on rowIndex
* @param {Number} rowIndex
* @returns Array|Object
* @memberof DataManager
*/
getData(rowIndex) {
return this.data[rowIndex];
}
hasColumn(name) {
return Boolean(this.columns.find(col => col.content === name));
}
@ -2537,7 +2548,9 @@ class CellManager {
if (isHeader || isFilter || !cell.column.format) {
contentHTML = cell.content;
} else {
contentHTML = cell.column.format(cell.content, cell);
const row = this.rowmanager.getRow(cell.rowIndex);
const data = this.datamanager.getData(cell.rowIndex);
contentHTML = cell.column.format(cell.content, row, cell.column, data);
}
if (this.options.enableTreeView && !(isHeader || isFilter) && cell.indent !== undefined) {

File diff suppressed because one or more lines are too long

View File

@ -684,7 +684,9 @@ export default class CellManager {
if (isHeader || isFilter || !cell.column.format) {
contentHTML = cell.content;
} else {
contentHTML = cell.column.format(cell.content, cell);
const row = this.rowmanager.getRow(cell.rowIndex);
const data = this.datamanager.getData(cell.rowIndex);
contentHTML = cell.column.format(cell.content, row, cell.column, data);
}
if (this.options.enableTreeView && !(isHeader || isFilter) && cell.indent !== undefined) {

View File

@ -570,6 +570,17 @@ export default class DataManager {
};
}
/**
* Returns the original data which was passed
* based on rowIndex
* @param {Number} rowIndex
* @returns Array|Object
* @memberof DataManager
*/
getData(rowIndex) {
return this.data[rowIndex];
}
hasColumn(name) {
return Boolean(this.columns.find(col => col.content === name));
}