Created
January 15, 2021 05:52
-
-
Save vijaywm/34c3c9a0deb81de9460d6efbfab45b00 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
prepare_report_data(data) { | |
this.data = data; | |
// prepare columns | |
this.data.columns.forEach((t) => { | |
t.title = t.label; | |
t.field = t.fieldname; | |
}); | |
// set column cell formatter for known fieldtypes, if not provided already in report_settings | |
// list of Tabulator formatters: http://tabulator.info/docs/4.9/format | |
this.data.columns.forEach((col) => { | |
if (!col.formatter) { | |
this.set_column_formatter(col); | |
} | |
}); | |
} | |
set_column_formatter(col) { | |
if (!col.fieldtype || col.fieldtype == "") { | |
if ( | |
this.data && | |
this.data.result && | |
this.data.result.length && | |
frappe.utils.is_html(this.data.result[0][col.fieldname]) | |
) | |
col.formatter = "html"; | |
} else if (col.fieldtype == "Link") { | |
col.formatter = function (cell) { | |
return `<a href='desk#Form/${ | |
col.options | |
}/${cell.getValue()}'>${cell.getValue()}</a>`; | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment