Skip to Content
avatar image
Former Member

How to clear simple form after submit the button using sapui5

I have created simple form and i want to clear all field after validation and submit the button.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Sep 18 at 09:12 PM

    Hello,

    There can be several ways to achieve this. The best two ways are as follows:

    1. If you are keeping a model which is assigned to the form (or fragment), then destroy the model or clear the values in the model.

    2. If values are not held in any model, then kill the form (or fragment) by assigning it to null and then using 'destroy' method.

    You can use the 'AfterClose' event of the fragment to achieve this.

    Please share your feedback such that we can help you to imporove your code line.

    Thanks, Piyush.

    SAP

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 30, 2017 at 11:26 AM
    -1

    Hi Kallesh KS ,

    You might be initialising the form (setting initial values to the fields binded to the form elements) in onInit function of the view.

    onInit : function () {

    this._initialiseForm();

    }

    initialiseForm:function()

    {

    //Binding the form with the model with initial set of values.

    }

    you just need to call this._initialiseForm function on submit and validation press (after the data is posted successfully)

    thanks

    Viplove

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 30, 2017 at 11:55 AM
    -1

    Hi,

    You can do it by accessing the FORM Properties by using Its ID.

    Like as shown below...

    var oForm = new sap.ui.getCore().byId("your Control unique ID");

    By the above code u can access the your form attributes...go to the console and do some R&D and you will get some solution for clearing the data from your FORM.Console is our best friend to resolve any kind of issues...

    Thanks ,

    Vamsi.

    Add comment
    10|10000 characters needed characters exceeded