How to change button's caption base on a field value

Hi all,

        I inserted a custom button in a section

diff: /**SCHEMA_DIFF*/[

            // Metadata for adding a cutom button to the page.

            {

                // Indicates that an operation of adding an item to the page is being executed.

                "operation": "insert",

                // Meta-name of the parent control item where the button is added.

                "parentName": "CombinedModeActionButtonsCardLeftContainer",

                // Indicates that the button is added to the control items collection

                // of the parent item (which name is specified in the parentName).

                "propertyName": "items",

                // Meta-name of the added button. .

                "name": "MainContactButton",

                // Supplementary properties of the item.

                "values": {

                    // Type of the added item is button.

                    itemType: Terrasoft.ViewItemType.BUTTON,

                    // Binding the button title to a localizable string of the schema.

                    caption: {bindTo: "getSendButtonCaption"},

                    // Binding the button press handler method.

                    click: {bindTo: "onSendClick"},

                    // Binding the property of the button availability.

                    enabled: {bindTo: "canSend"},

                    visible: {bindTo: "showButtonSend"},

                    style: Terrasoft.controls.ButtonEnums.style.GREEN,

                    // Setting the field location.

                    "layout": {

                        "column": 1,

                        "row": 6,

                        "colSpan": 1

                    }

                }

            }

        ]

I have bind its caption with a function "getSendButtonCaption", but it doesn't work when I changed value

getSendButtonCaption: function() {

                var activeRow = this.get("ActiveRow");

                if (activeRow) {

                    var sendTime = this.get("GridData").get(activeRow).get("UsrSendTime");

                    if (sendTime) {

                        if (sendTime.value.toUpperCase() === "FC73B30F-9E29-48BA-8A9E-3C4247CFF22A") {

                            return this.get("Resources.Strings.SendManuallyButtonCaption");    

                        } else if (sendTime.value.toUpperCase() === "47AB118D-84C9-4846-B916-8DC40CF0B333") {

                            return this.get("Resources.Strings.ScheduleSendButtonCaption");

                        }

                    }

                }

                return "";

            }

This solution works well in page.Why?

Thanks

Like 0

Like

7 comments

Eugene Podkovka,

Hi Eugene,

          I had read this document before. In that case, the button's caption has bound with resource and doesn't change anymore, but I want to change its caption by changing the value of dropdownlist like the button "Send" in the section "Marketing\Email".

Thanks

Toan Mai,

The button should be added both to the page and to the section. You only added it to the section.

Eugene Podkovka,

I have implemented in section and page. As I said in my question, it only works  in page.

Toan Mai,

No. The code that you added to the post does not contain the part that exists on a page. 

Eugene Podkovka,

Hi Eugene,

         Please send me your email, I will send you my page and section source code or the demo site which had been deployed that package. Or will I send them to support team?

Thanks

Toan Mai,

Try to contact the support.

Show all comments