Results 1 to 8 of 8

Thread: beforechange event on combobox

  1. #1
    Sencha User
    Join Date
    Oct 2013
    Posts
    21

    Default Answered: beforechange event on combobox

    Hi. Why comboboxes does not have an beforechange event?

    In my case, i have some fields that are dependents of the combobox value. So, if the combobox value changes, and if the fields are set, it is necessary to inform the user that those fields are not coherent anymore. So, the user has two choices, accept the value and clear the dependent fields OR do not accept the value and keep everything as it is.
    The thing is, if i do this with the change event, and if the user rejects the change, i will set the value to the old value, but the prompt will appear again and again, everytime the user rejects the change... This does not make any sense at all. To solve this, i need to set a flag to true, so that the change handler does not run again. It should not be this way. It would be so much easier with the beforechange event.

  2. Form fields do not have beforeXXXX events. You could maybe solve the problem by suspending events while you manipulate fields values programmatically and resume them afterwards to avoid the infinite event loop.

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

    Default

    Form fields do not have beforeXXXX events. You could maybe solve the problem by suspending events while you manipulate fields values programmatically and resume them afterwards to avoid the infinite event loop.
    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


  4. #3
    Sencha Premium User
    Join Date
    Jan 2013
    Posts
    62
    Answers
    2

    Default

    Quote Originally Posted by jsakalos View Post
    You could maybe solve the problem by suspending events while you manipulate fields values programmatically and resume them afterwards to avoid the infinite event loop.
    Unless your listeners are on a controller and suspendEvents is ignored.

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

    Default

    Well, you can suspend events also on controller: http://docs.sencha.com/extjs/4.2.2/#...-suspendEvents
    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


  6. #5
    Sencha Premium User varsos's Avatar
    Join Date
    Feb 2008
    Location
    Long Island, NY
    Posts
    367
    Answers
    6

    Default


    "...This does not make any sense at all" is right, if you assume that the change event means "user changed event", but this is not true in Extjs 4.x.

    Many of us migrating apps from older Extjs to 4.x were in for a surprise in this area.
    The checkChangeEvents propery controls what triggers the "change" event and by default pretty much everything a user does of anything you do to change the field's value programmatically.

    So, Mr. Sakalos' suggestion is a good idea, unless you really want to alter this behavior globally and make the change event fire with only user interactions.
    varsos

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

    Default

    Now "change" means: somebody called setValue. However, you can call setRawValue to bypass change, validation, conversions.
    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


  8. #7
    Sencha Premium User
    Join Date
    Jan 2013
    Posts
    62
    Answers
    2

    Default

    Quote Originally Posted by jsakalos View Post
    Well, you can suspend events also on controller: http://docs.sencha.com/extjs/4.2.2/#...-suspendEvents
    Thanks! I didn't know that.

  9. #8
    Sencha User
    Join Date
    Oct 2013
    Posts
    21

    Default

    thanks for the support.

    EDIT: actually, the suspendEvents can solve this issue, but i will not use it. but, this method, is usefull to load data into the form without the events being fired. thanks

Posting Permissions

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