Hello Creatio community,
We're trying to hide/show items in print section button based on specific conditions. The filter works fine in section page and edit page but it doesn't work when we try to open the edit page from the section page.
When we try to open the edit page from the section list the filter that we have made in both section and page doesn't apply and all the items in print button are displayed. Examples below.
1. Print button in section list
2. Print button when we open edit page (from reload)
3. Print button when edit page is open from application section list
Application page:
preparePrintFormsMenuCollection: function (printForms) { this.callParent(arguments); printForms.eachKey(function (key, item) { if(key =="ebd9e198-9d05-21b7-6d30-4f79eb6cf2ea") { item.set("Visible", true); } else{ item.set("Visible", false); } }, this); },
Application section:
isSectionPrintFormEnabled: function(reportId) { if (!this.isAnySelected()) { return false; } if (this.isSingleSelected() && !this.get("SelectAllMode")) { var applicationId = this.$ActiveRow; if(reportId == "ebd9e198-9d05-21b7-6d30-4f79eb6cf2ea"){ return true; } return false; } else { const reportCollection = this.get(this.moduleSectionPrintFormsCollectionName); const report = reportCollection.get(reportId); return (report && report.get("PrintFormType") !== Terrasoft.ConfigurationEnums.ReportType.Word) || !this.get("SelectAllMode"); } },
The function "preparePrintFormsMenuCollection" is called every time the application page is opened. When the application page is opened from the section list (combined mode) the print button is not reloaded and keeps the older values.
How can we reload the items of the print button when the edit page is opened from section page?
Regards,
Lirzae
Like
Hello Lirzae,
You could try the following. When a row is selected in the section, retrieve the collections of printables for the section, then look through and set the Visible property based on the values of the selected row. Something like this:
rowSelected: function(primaryColumnValue) { this.callParent(arguments); // get data for selected row var row = this.getGridData().get(primaryColumnValue) // get printables collection var reportCollection = this.get(this.moduleSectionPrintFormsCollectionName); Terrasoft.each(reportCollection, function(report) { if (row.get("UsrSomeField") == "Some Value" && report.get("Id") == "TheReportId") { report.set("Visible", false); } else { report.set("Visible", true); } }, this); }
Note, I've not tried that before so not sure if it will work, but that is what I would attempt first. Also, the fields available in the "row" variable would depend on the column layout of the section. If you need to ensure a value is available, you'll want to add that to the section ESQ like this:
initQueryColumns: function(esq) { this.callParent(arguments); if (!esq.columns.contains("UsrSomeField")) { esq.addColumn("UsrSomeField"); } }
Ryan
Ryan Farley,
I tried using "rowselected" method but this only works in section list page. When I try to open the edit page from section list the print button shows all the items.
The other method that I used "preparePrintFormsMenuCollection" is called when the edit page is opened but doesn't reload the print button items.
Is there any other method that can reload print button items when the edit page is opened from the section list?
put the same code i mean the Follwoing code in section page as well and it will works fine
preparePrintFormsMenuCollection: function (printForms) {
this.callParent(arguments);
printForms.eachKey(function (key, item) {
if(key =="ebd9e198-9d05-21b7-6d30-4f79eb6cf2ea")
{
item.set("Visible", true);
}
else{
item.set("Visible", false);
}
}, this);
},