I am trying to hide/show print button based on the field Data. I tried to override SeparateModeReportsButton, CombinedModeReportsButton in Diff but It didn't work. Any luck in finding the solution for this
Like
Hello,
In order to hide/show the "Print" button based on role you need to modify the method setReportsButtonVisible in the schema BaseDataView and set the value of an attribute "IsSectionPrintButtonVisible" based on your condition.
For example, here is a full code of the schema BaseDataView where we hide the "Print" button if the user is not a System Administrator (id 83a43ebc-f36b-1410-298d-001e8c82bcad):
define("BaseDataView", [], function() {
return {
diff: /**SCHEMA_DIFF*/[]/**SCHEMA_DIFF*/,
methods: {
setReportsButtonVisible: function() {
this.callParent(arguments);
this.set("IsSectionPrintButtonVisible", false);
var currentUserId = Terrasoft.SysValue.CURRENT_USER.value;
var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
rootSchemaName: "SysAdminUnitInRole"
});
var esqFirstFilter = esq.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, "SysAdminUnit", currentUserId );
var esqSecondFilter = esq.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL,
"SysAdminUnitRoleId", "83a43ebc-f36b-1410-298d-001e8c82bcad");
esq.filters.logicalOperation = Terrasoft.LogicalOperatorType.AND;
esq.filters.add("esqFirstFilter", esqFirstFilter);
esq.filters.add("esqSecondFilter", esqSecondFilter);
esq.getEntityCollection(function (result) {
if (result.success) {
this.set("IsSectionPrintButtonVisible", true);
}
else {
this.set("IsSectionPrintButtonVisible", false);
}
}, this);
}
}
};
}
);
Best reBest regards,
Orkhan Gojaev