Results 1 to 4 of 4

Thread: Change listener in form

  1. #1
    Sencha User medley's Avatar
    Join Date
    Apr 2008
    Location
    Luxembourg
    Posts
    128
    Vote Rating
    0
      0  

    Exclamation Change listener in form

    Hello,

    I have a grid and form. When I click on one row of the grid, the form is loaded with the selected record.
    1 - When I change the value of one field, I disable the grid (see change event of my controller).
    2 - When I click on the button 'Cancel', I reload the form with the selected row of the grid and I enable the grid (function "cancelEditService") . However, after the reload, the event "change" fires and I don't want it to fire.

    Code:
       
    Ext.define('EPplatosRegistry.controller.Services', {
    extend : 'Ext.app.Controller',
    ...
                'serviceedit > textfield': {
                    change: {
                        fn: this.textFieldChange,
                        buffer: 500 // Delay the request by half a second
                     }
                }
            });
        },
    ...
        cancelEditService : function(button) {
            var grid = this.getServiceslist(), record = grid.getSelectionModel().getLastSelected(), form = this.getServiceedit(),toolbar = form.getDockedComponent('buttons'),
            saveButton = toolbar.getComponent('save'), cancelButton = toolbar.getComponent('cancel'), 
            editButton = toolbar.getComponent('edit');
            var items = form.items;
            var i = 0;
            for(i = 0; i < items.length; i += 1){
               items.getAt(i).setReadOnly(true);
            }
            form.loadRecord(record);
            grid.enable();
            editButton.enable(); saveButton.disable(); cancelButton.disable();
        },
        ...
    
        textFieldChange: function(textField, newValue, oldValue, options) {
            var grid = this.getServiceslist(), form = this.getServiceedit(),toolbar = form.getDockedComponent('buttons'),
            saveButton = toolbar.getComponent('save'), cancelButton = toolbar.getComponent('cancel'), 
            editButton = toolbar.getComponent('edit');
            if(textField.name != 'revision') {
                saveButton.enable();cancelButton.enable();editButton.disable();
                grid.disable();
            }    
        }
    });


    Thanks for help
    Medley


  2. #2
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364
    Answers
    102
    Vote Rating
    86
      0  

    Default

    You code is given gem headaches! You should code one command per line.

    That said, you can use the removeListner or short hand un() method to remove the event.

    You can also suppress the event and resume it.

  3. #3
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,791
    Answers
    585
    Vote Rating
    394
      0  

    Default

    Perhaps you could use isDirty() with trackResetOnLoad?

    http://docs.sencha.com/ext-js/4-0/#!...method-isDirty

    If the form is dirty you disable the grid, if it isn't then you enable it.

  4. #4
    Sencha User medley's Avatar
    Join Date
    Apr 2008
    Location
    Luxembourg
    Posts
    128
    Vote Rating
    0
      0  

    Default

    I found this property "suspendCheckChange" which can have the value 0 or 1. It works but I don't know if I can use it..

    Medley

Posting Permissions

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