Question

One button with two function ? Is it possible ?

Hi team,

I need to have one button and when i click the button for the first time it should call a method and second it should call second method.

Alternate solution If the above is not possible : 

Two button one should be disabled when another one is clicked . 

Enabled property set to method is not working as im having this button in edit page and im using subscribe message method to display method to display the buttons .

 

regards,

sethuraghav N

Like 0

Like

2 comments

It's possible to create a button that will execute one method after another on click in the following way:

define("AccountPageV2", [], function() {

    return {

        // Name of the section object schema.

        entitySchemaName: "Account",

        // Method of the section view model.

        attributes: {

            "isButtonEnabled": {

                "dataValueType": Terrasoft.DataValueType.BOOLEAN,

                "type": Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,

                "value": true

            },

            "isMethodRun": {

                "dataValueType": Terrasoft.DataValueType.BOOLEAN,

                "type": Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,

                "value": false

            }

        },

        methods: {

            sayHello: function(){

                this.showInformationDialog("Hello!");

            },

            sayBye: function(){

                this.showInformationDialog("Bye!");

            },

            onBtnClick: function(){

                if(this.get("isMethodRun")){

                    this.sayBye();

                    this.set("isButtonEnabled", false);

                } else {

                    this.sayHello();

                    this.set("isMethodRun", true);

                    this.set("isButtonEnabled", true);

                }

            }

            

        },

        //Display button in the section.

        diff: /**SCHEMA_DIFF*/[

            // Metadata for adding a custom button to a section.

            {

                // The operation of adding a component to the page is in progress..

                "operation": "insert",

                // The meta name of the parent container to which the button is added.

                "parentName": "AccountPageV2CommonControlGroupControlGroup-wrap",

                // The button is added to the parent component's collection.

                "propertyName": "items",

                // The meta-name of the button to be added.

                "name": "MainContactSectionButton",

                // Properties passed to the component's constructor.

                "values": {

                    // The type of the component to add is the button.

                    "itemType": Terrasoft.ViewItemType.BUTTON,

                    // Bind the button header to the localizable string of the schema.

                    "caption": { bindTo: "Resources.Strings.MyButton" },

                    // Bind the button click handler method.

                    "click": { bindTo: "onBtnClick" },

                    "enabled": {bindTo: "isButtonEnabled"},

                    // Setting the location of the button.

                    "layout": {

                        "column": 1,

                        "row": 1,

                        "colSpan": 2

                    }

                }

            }

        ]/**SCHEMA_DIFF*/

    };

});

Alina Kazmirchuk,

Thank you . I will try this . 

 

Alina Kazmirchuk,

Show all comments