Action Buttons in Column
Use Case
As seen above, we want an inline “Close” button for each row in the above report. Clicking on this button should close the corresponding ToDo and refresh the report automatically.
The Report Python Script
The logic below is pretty simple. We are fetching the status
, description
and name
for the ToDo documents that are either created by or allocated to the currently logged in user using or_filters
:
The JS Script
We will basically be making (a clever 😆) use of the formatter
feature of query report scripts to render a button in every row of the “Close Action” column (field name is name):
Some Notes From Above Script
-
We are using the
add_inner_button
JavaScript API to add a button at the top of the report page: -
frappe.query_report
refers to the currently open report view. (analogous tocur_frm
in form view andcur_list
in list view) -
On click of a button, we are triggering the
close_todo
method of the report script: