Hi,
i want to add checkbox in query report and want to perform some actions on selected rows like delete, submit etc.
Hi,
i want to add checkbox in query report and want to perform some actions on selected rows like delete, submit etc.
This is what i’ve tried but checkboxes are not clickable.
select
0 as ":Check:20",
name as "Name:Link/Sales Invoice:200"
from
`tabSales Invoice`;
Maybe its work on custom report
Yes its working on customs reports but i want it to work on query and script reports.
Yes it is.
I’ve successfully got check boxes on report but now unable to access selected records,
i need to get list of selected invoices number when i click on my custom button.
here is what i’ve tried.
frappe.query_reports["Testing"] = {
onload: function(report) {
report.page.add_inner_button(__("Test"), function() {
let selected_rows = cur_frm.doc["item"].grid.get_selected();
console.log(selected_rows);
});
},
get_datatable_options(options) {
return Object.assign(options, {
checkboxColumn: true
});
}
};
but got this error:
VM1924:5 Uncaught TypeError: Cannot read property 'doc' of null
at <anonymous>:5:32
at HTMLButtonElement.i (page.js:452)
at HTMLButtonElement.dispatch (jquery.min.js:3)
at HTMLButtonElement.r.handle (jquery.min.js:3)
You can get selected rows of report having checkbox as below:
onload: function() {
frappe.query_report.page.add_inner_button(__("Get Selected"), function() {
var selected_rows = [];
$('.dt-scrollable').find(":input[type=checkbox]").each((idx, row) => {
if(row.checked){
console.log("*** selected row id : " + idx);
selected_rows.push(frappe.query_report.data[idx]);
}
});
});
},
I am trying like this, but older version like 6.xx maybe doesn’t support onload
inside query_report
. Can you please tell me any alternate way.
Can you please explain how did you get the checkboxes?
Found it. Added below function to frappe.query_report["<report-name>"]
object
get_datatable_options(options) {
return Object.assign(options, {
checkboxColumn: true,
});
}
Can something similar be done in html? I want to print an image, if the checkbox is selected
With Version 13 the right way to do this is in your_report.js
:
frappe.query_reports["Your Report"] = {
get_datatable_options(options) {
return Object.assign(options, {
checkboxColumn: true,
});
},
onload: function(report) {
report.page.add_action_item(__("Test"), function() {
let checked_rows_indexes = report.datatable.rowmanager.getCheckedRows();
let checked_rows = checked_rows_indexes.map(i => report.data[i]);
/* DO WHATEVER YOU LIKE WITH YOUR `checked_rows`! */
// debugger;
});
},
};
Works fine in Version-12 too. Thankyou
I have got the selected records but now I want to export only selected records from the script report.
Can anyone help me with this??