raghav
January 4, 2019, 6:13am
1
I am trying to add colour to the text of each cell. I am using the following code :
"formatter":function (row, cell, value, columnDef, dataContext, default_formatter) {
value = default_formatter(row, cell, value, columnDef, dataContext);
if(columnDef.id == "Status"){
value = "<span style='color:blue;font-weight:bold';>" + value + "</span>";
}
return value;
}
Im getting this error:
1 Like
It seems you are applying color changes in custom report. Is it script report ??
And where you included the above code ??
raghav
January 23, 2019, 4:58am
3
Yes, It is a script report. I have included it in my script report’s js file.
Could you share screenshot or code of JS ?
v11 frappe uses datatable (changed from slickgrid) and the signature for formatter has changed to below.
"formatter": function (value, row, column, data, default_formatter) {
Change your code accordingly
2 Likes
@vijaywm @apkrajar
I also have the same error
Uncaught (in promise) TypeError: default_formatter is not a function
my js file is
frappe.query_reports['All Full Funnel'] = {
"formatter": function (value, row, cell, column, data, default_formatter) {
value = default_formatter(row, cell, value, column, data);
if (data.Stage < 90) {
value = `<span style='color:red!important;font-weight:bold'>${value}</span>`;
}
if (data.Stage == 90) {
value = `<span style='color:blue!important;font-weight:bold'>${value}</span>`;
}
if (data.Stage > 90) {
value = `<span style='color:green!important;font-weight:bold'>${value}</span>`;
}
return value;
},
};
@raghav
did you fix the error
vijaywm:
“formatter”: function (value, row, column, data, default_formatter) {
@Alaa_Badri please make the below change and try
"formatter": function (value, row, cell, column, data, default_formatter) {
to
"formatter": function (value, row, column, data, default_formatter) {
vijaywm:
“formatter”: function (value, row, column, data, default_formatter) {
@vijaywm thanks for your reply but i got the same error
VM837:13 Uncaught (in promise) TypeError: default_formatter is not a function
at Object.formatter (<anonymous>:13:13)
at format (query_report.js:662)
at ft.getCellContent (frappe-datatable.cjs.js:3323)
at ft.getCellHTML (frappe-datatable.cjs.js:3287)
at frappe-datatable.cjs.js:4093
at Array.map (<anonymous>)
at mt.getRowHTML (frappe-datatable.cjs.js:4093)
at Object.generate (frappe-datatable.cjs.js:4584)
at e.value (frappe-datatable.cjs.js:4353)
at e.value (frappe-datatable.cjs.js:4436)
can you do just inside the formatter function and share output
"formatter": function (value, row, cell, column, data, default_formatter) {
console.log(row, cell, value, column, data);
value = default_formatter(row, cell, value, column, data);
eslean
August 25, 2022, 11:00am
13
Will this work on Custom Script for v12?