Pass row, column and data as context to format
This commit is contained in:
parent
7683892142
commit
ee0f6e512e
15
dist/frappe-datatable.cjs.js
vendored
15
dist/frappe-datatable.cjs.js
vendored
@ -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) {
|
hasColumn(name) {
|
||||||
return Boolean(this.columns.find(col => col.content === name));
|
return Boolean(this.columns.find(col => col.content === name));
|
||||||
}
|
}
|
||||||
@ -2538,7 +2549,9 @@ class CellManager {
|
|||||||
if (isHeader || isFilter || !cell.column.format) {
|
if (isHeader || isFilter || !cell.column.format) {
|
||||||
contentHTML = cell.content;
|
contentHTML = cell.content;
|
||||||
} else {
|
} 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) {
|
if (this.options.enableTreeView && !(isHeader || isFilter) && cell.indent !== undefined) {
|
||||||
|
|||||||
15
dist/frappe-datatable.js
vendored
15
dist/frappe-datatable.js
vendored
@ -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) {
|
hasColumn(name) {
|
||||||
return Boolean(this.columns.find(col => col.content === name));
|
return Boolean(this.columns.find(col => col.content === name));
|
||||||
}
|
}
|
||||||
@ -2537,7 +2548,9 @@ class CellManager {
|
|||||||
if (isHeader || isFilter || !cell.column.format) {
|
if (isHeader || isFilter || !cell.column.format) {
|
||||||
contentHTML = cell.content;
|
contentHTML = cell.content;
|
||||||
} else {
|
} 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) {
|
if (this.options.enableTreeView && !(isHeader || isFilter) && cell.indent !== undefined) {
|
||||||
|
|||||||
@ -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) {
|
hasColumn(name) {
|
||||||
return Boolean(this.columns.find(col => col.content === name));
|
return Boolean(this.columns.find(col => col.content === name));
|
||||||
}
|
}
|
||||||
@ -2537,7 +2548,9 @@ class CellManager {
|
|||||||
if (isHeader || isFilter || !cell.column.format) {
|
if (isHeader || isFilter || !cell.column.format) {
|
||||||
contentHTML = cell.content;
|
contentHTML = cell.content;
|
||||||
} else {
|
} 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) {
|
if (this.options.enableTreeView && !(isHeader || isFilter) && cell.indent !== undefined) {
|
||||||
|
|||||||
11
index.html
11
index.html
File diff suppressed because one or more lines are too long
@ -684,7 +684,9 @@ export default class CellManager {
|
|||||||
if (isHeader || isFilter || !cell.column.format) {
|
if (isHeader || isFilter || !cell.column.format) {
|
||||||
contentHTML = cell.content;
|
contentHTML = cell.content;
|
||||||
} else {
|
} 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) {
|
if (this.options.enableTreeView && !(isHeader || isFilter) && cell.indent !== undefined) {
|
||||||
|
|||||||
@ -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) {
|
hasColumn(name) {
|
||||||
return Boolean(this.columns.find(col => col.content === name));
|
return Boolean(this.columns.find(col => col.content === name));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user