Results 1 to 5 of 5

Thread: Reset form fields in MVVM

  1. #1

    Default Reset form fields in MVVM

    Hi, I would like to know how to reset the items in form panel on clicking 'reset' button in view, from ViewController (using MVVM architecture)?

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,409
    Answers
    716

    Default

    In your view:

    Code:
    // toolbar
    text: 'Reset',
    handler : 'resetForm'
    In your ViewController:

    Code:
       resetForm : function (button) {
           var form   = this.getView();
           ..
       }

  3. #3

    Default

    hi, I did as you mentioned above, but it is not working still. I am able to see the controll goes to that respective method in ViewController.

    Getting error as "Uncaught TypeError: undefined is not a function"

    In View,
    -----------------------------
    {
    xtype : 'button',
    text : 'Reset',
    iconCls : 'reset-icon',
    handler : 'resetRFButton',
    }
    -----------------------------

    In view controller,
    -----------------------------
    resetRFButton: function(){
    console.log('in reset');
    console.log('Form clear->'+this.getView().reset());
    }
    -------------------------------

  4. #4
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,664
    Answers
    512

    Default

    It seems that this.getView() does not return an instance of form - check it. You may also try this.getView().getForm().reset();
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid MultiSearch Plugin, Grid MultiSort Plugin, Configuring ViewModel Hierarchy


  5. #5
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,664
    Answers
    512

    Default

    Sorry, I have by mistake deleted your post where you say that it does not work.

    Well, run it through standard debugging procedures, e.g. stop the execution just before reset call, check if you get the correct view with getView, etc.

    Or post a runnable showcase at https://fiddle.sencha.com we can take a deeper look.
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid MultiSearch Plugin, Grid MultiSort Plugin, Configuring ViewModel Hierarchy


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •