Printable

Hello, I need some help in printables . I want printable to be enabled based on Status . Example if status of selected record is Completed then printable must be enabled.

I have override  "isSectionPrintFormEnabled" method in my section page as i noticed it is the method which bind to enabled value in "initSectionPrintForms" method in PrintReportUtilities . It is not working as expected as printable is always showing as disabled.

Thank You.

Like 0

Like

3 comments

Dear Sushma,

Please find the example of button being enable in the Order section.

1. You need to override your section schema.  

2. Modify the diff of the button. Add "enabled" property to it. Bind it to your custom attribute. e.g.

{
	"operation": "merge",
	"parentName": "RightContainer",
	"propertyName": "items",
	"name": "PrintButton",
	"values": {
		itemType: Terrasoft.ViewItemType.BUTTON,
		"caption": {"bindTo": "Resources.Strings.PrintButtonCaption"},
		"classes": {"wrapperClass": ["actions-button-margin-right"]},
		"controlConfig": {"menu": {"items": {"bindTo": "CardPrintMenuItems"}}},
		"visible": {"bindTo": "IsCardPrintButtonVisible"},
		"enabled": {"bindTo": "IsPrintableEnabled"}
		}
}

3. Add the attribute, which default value is set to false. e.g.

"IsPrintableEnabled": {
	"type": Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
	"dataValueType": Terrasoft.DataValueType.BOOLEAN,
	"value": false
}

4. Add custom method, which will set the attribute value to true after status check on initialising the page. e.g.

methods: {
	onEntityInitialized: function() {
		this.callParent(arguments);
		this.checkStatus();
	},
	checkStatus: function() {
		var status = this.get("Status").value;
		if (status !== "1f3ad326-effd-4ac3-a3e2-957e7def3684") {
		   this.set("IsPrintableEnabled", true);
	    }
    }
}

Hope you will find it helpful.

Regards,

Anastasia

Anastasia Botezat,

Thank you for reply, I implemented the example as you have suggested.

It seems that when I am opening the record from my section view, it is still displaying the PRINT button. However, once the record is open, when I reload the same page, it's disabling the button - as expected.



My reasoning is 'onEntityInitialized' method is not available in the section page to change the status of the "IsPrintableEnabled" attribute.

Dear Sushma,

in this case I would like to offer you to return to the approach overriding the PrintReportUtilities schema. Particularly draw your attention to getRowPrintButtonVisible method. It is responsible for displaying Print button in the rows, when clicking on records. As I understood this is of your interest. Please override this method to add status validation. The idea is that this method should return false in case status does not allow printables.

Also, you might be also interested in getCardPrintButtonVisible method responsible for the button in the section header.

Regards,

Anastasia

Show all comments