1. #51
    Ext User
    Join Date
    Jun 2009
    Posts
    21
    Vote Rating
    0
    Gonfi is on a distinguished road

      0  

    Default change event not fired on item removal

    change event not fired on item removal


    hello,

    currently the change event only fires when ADDING items to the selection, not when removing single items or all at once.

    i have hacked in a couple lines to get those events too. it's dirty, clicking the x button on the right fires the change for every selected item, plus once. but at least it fires. x-removing single items fires correctly. maybe you want to take it from here ;-)

    clearValue : function(supressRemoveEvent){
    var hadItems = this.items.getCount() > 0;
    var oldVal = (hadItems) ? this.getValue() : "";

    Ext.ux.form.SuperBoxSelect.superclass.clearValue.call(this);
    this.preventMultipleRemoveEvents = supressRemoveEvent || this.supressClearValueRemoveEvents || false;
    this.removeAllItems();
    this.fireEvent('clear',this);

    if (hadItems) {
    this.fireEvent('change',this, "", oldVal);
    }

    return this;
    },

    around line 1121:

    'remove': function(item){
    var valueBefore = this.getValue();

    if(this.fireEvent('beforeremoveitem',this,item.value) === false){
    return;
    }
    this.items.removeKey(item.key);
    if(this.removeValuesFromStore){
    if(this.usedRecords.containsKey(item.value)){
    this.store.add(this.usedRecords.get(item.value));
    this.usedRecords.removeKey(item.value);
    this.sortStore();
    if(this.view){
    this.view.render();
    }
    }
    }
    if(!this.preventMultipleRemoveEvents){
    this.fireEvent.defer(250,this,['removeitem',this,item.value, this.findInStore(item.value)]);

    this.fireEvent('change',this, this.getValue(), valueBefore);

    }
    this.preventMultipleRemoveEvents = false;
    },


    also, around line 1148, this caused a problem in the new ext3 version, and is fine when removed:

    destroy: function(){
    this.collapse();
    //this.autoSize().manageClearBtn().validateValue(); //causes problem
    },

    it would be nice if there was a rendering that uses standard field height.

    thanks for the component,
    greetings

  2. #52
    Ext JS Premium Member
    Join Date
    May 2007
    Posts
    698
    Vote Rating
    3
    danh2000 is on a distinguished road

      0  

    Default


    @Gonfi,

    Form fields are not supposed to fire the change event until just before blur. If it fires when adding items, I'd say that's the bug, not that it doesn't fire when removing.

    I'm very busy at the moment, but will look at the events and aim to get a new release up within a week, however I'll be following suit from other form fields so you won't get the event fired in the places you've added it.

    Thanks.

    Dan

  3. #53
    Ext User
    Join Date
    Feb 2009
    Posts
    26
    Vote Rating
    0
    jackjia is on a distinguished road

      0  

    Default


    Wow, very nice extension. Thanks for sharing.

  4. #54
    Sencha User GraemeBryce's Avatar
    Join Date
    Sep 2007
    Location
    Scotland
    Posts
    89
    Vote Rating
    0
    GraemeBryce is on a distinguished road

      0  

    Default


    This is indeed a great control.

    One thing I have spent hours trying to figure out (ashamed to admit it really is hours!) is why when all the values are removed does the field no longer exist in a form post or a request the the basic form getValues.

    This means i am unable to clear the value at the server unless I detect the field is acually missing.

    I want to just post the field with no value or even '' but no luck.

    can anyone suggest a way? or even why it is doing it.

  5. #55
    Ext JS Premium Member
    Join Date
    May 2007
    Posts
    698
    Vote Rating
    3
    danh2000 is on a distinguished road

      0  

    Default


    @jackjia Thanks.

    @GraemeBryce Thanks. I've just implemented a forceFormValue option - when set to true, you will get an empty string in the the parent BasicForm getValues method or when you manually submit the raw dom form.

    I'll release the next version here in the next 24 hours.

    Dan

  6. #56
    Sencha User GraemeBryce's Avatar
    Join Date
    Sep 2007
    Location
    Scotland
    Posts
    89
    Vote Rating
    0
    GraemeBryce is on a distinguished road

      0  

    Default


    Great.

    I look forward to seeing how you did it. Many thanks for the continued support of this extension.

  7. #57
    Ext JS Premium Member
    Join Date
    May 2007
    Posts
    698
    Vote Rating
    3
    danh2000 is on a distinguished road

      0  

    Default


    Quote Originally Posted by GraemeBryce View Post
    Great.

    I look forward to seeing how you did it. Many thanks for the continued support of this extension.
    An explanation for you, so you don't have to hunt:

    The values come from hidden inputs - 1 for each selected item, they don't come from the input el (where you type for autocomplete). With this in mind....

    -I was removing the name attribute from the input el, so that it was not included in the raw form submission. Now, if you use the new forceFormValue config, I manage the name attribute of the input el, so it does get included if no items (zero items) have been selected.

    -I have always intercepted the getValues method of the parent BasicForm - I still intercept this method, but I now inject a blank string into the return values if no items (zero items) have been selected.

    Regards,

    Dan

  8. #58
    Ext JS Premium Member
    Join Date
    May 2007
    Posts
    698
    Vote Rating
    3
    danh2000 is on a distinguished road

      0  

    Default


    I've update the first post in this linked thread with a new version containing:

    -Fix to prevent the component receiving focus when reset is called.
    -Removed unnecessary usage of trim.
    -Fixed bug in setValueEx method.
    -Added a new forceFormValue config to force form values (submission or BasicForm.getValues) even when no items selected

    The amount of functionality X Ext Versions X Browser Combinations are quite an overhead to test, so please go easy on me if I've broken anything and you find errors - I'll do what I can to resolve any issues in a timely manner.

    Regards,

    Dan

  9. #59
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,546
    Vote Rating
    64
    Animal is a jewel in the rough Animal is a jewel in the rough Animal is a jewel in the rough

      0  

    Default


    Small bug. When disabling the overall widget, the items are disabled, but their KeyMaps are not disabled, so you can still interact with the widget - it's not fully disabled.

    Ext.ux.form.SuperBoxSelectItem needs

    Code:
        setupKeyMap : function(){
            this.keyMap = new Ext.KeyMap(this.lnk, [
                {
                    key: [
                        Ext.EventObject.BACKSPACE, 
                        Ext.EventObject.DELETE, 
                        Ext.EventObject.SPACE
                    ],
                    fn: this.preDestroy,
                    scope: this
                }, {
                    key: [
                        Ext.EventObject.RIGHT,
                        Ext.EventObject.DOWN
                    ],
                    fn: function(){
                        this.moveFocus('right');
                    },
                    scope: this
                },
                {
                    key: [Ext.EventObject.LEFT,Ext.EventObject.UP],
                    fn: function(){
                        this.moveFocus('left');
                    },
                    scope: this
                },
                {
                    key: [Ext.EventObject.HOME],
                    fn: function(){
                        var l = this.owner.items.get(0).el.focus();
                        if(l){
                            l.el.focus();
                        }
                    },
                    scope: this
                },
                {
                    key: [Ext.EventObject.END],
                    fn: function(){
                        this.owner.el.focus();
                    },
                    scope: this
                },
                {
                    key: Ext.EventObject.ENTER,
                    fn: function(){
                    }
                }
            ]);
            this.keyMap.stopEvent = true;
        },
        onEnable: function() {
            Ext.ux.form.SuperBoxSelectItem.superclass.onEnable.apply(this, arguments);
            this.keyMap.enable();
        },
        onDisable: function() {
            Ext.ux.form.SuperBoxSelectItem.superclass.onDisable.apply(this, arguments);
            this.keyMap.disable();
        },

  10. #60
    Ext JS Premium Member
    Join Date
    May 2007
    Posts
    698
    Vote Rating
    3
    danh2000 is on a distinguished road

      0  

    Default


    Thanks Animal - fix included for next release

Thread Participants: 95

  1. Animal (3 Posts)
  2. jay@moduscreate.com (1 Post)
  3. Condor (1 Post)
  4. stever (1 Post)
  5. mystix (5 Posts)
  6. MD (1 Post)
  7. JorisA (1 Post)
  8. randomY (1 Post)
  9. DigitalSkyline (1 Post)
  10. sj137 (3 Posts)
  11. boggle (1 Post)
  12. danh2000 (71 Posts)
  13. ostghost (1 Post)
  14. lossendae (1 Post)
  15. ZooKeeper (1 Post)
  16. greco (1 Post)
  17. Fredric Berling (1 Post)
  18. GraemeBryce (2 Posts)
  19. Strati (2 Posts)
  20. syscobra (2 Posts)
  21. boonkerz (4 Posts)
  22. Sesshomurai (3 Posts)
  23. shamansoft (1 Post)
  24. dorgan (2 Posts)
  25. mjhaston (1 Post)
  26. radtad (5 Posts)
  27. Joyfulbob (2 Posts)
  28. crysfel (1 Post)
  29. armandoxxx (2 Posts)
  30. jarlau (1 Post)
  31. lacco (1 Post)
  32. abraxxa (38 Posts)
  33. prometheus (1 Post)
  34. pops (1 Post)
  35. raphac (1 Post)
  36. Scorpie (2 Posts)
  37. supercharge2 (4 Posts)
  38. jmiguel (2 Posts)
  39. ash11tw (2 Posts)
  40. wojan (1 Post)
  41. ryzmen (1 Post)
  42. nmohler (2 Posts)
  43. wki01 (2 Posts)
  44. gacowarlock (1 Post)
  45. kora.kanchan (1 Post)
  46. senacle (3 Posts)
  47. genie_vn (1 Post)
  48. sergey.s (1 Post)
  49. Grolubao (10 Posts)
  50. mathec (1 Post)
  51. jackjia (1 Post)
  52. polydyne (1 Post)
  53. Antjac (1 Post)
  54. Thomas Triplet (1 Post)
  55. Gonfi (1 Post)
  56. kleins (1 Post)
  57. talha06 (1 Post)
  58. scishop (1 Post)
  59. eztam (2 Posts)
  60. frederickd (10 Posts)
  61. dusoo (2 Posts)
  62. iv_ekker (3 Posts)
  63. pym (1 Post)
  64. sudhirhv (3 Posts)
  65. lanhun (14 Posts)
  66. wcasado (1 Post)
  67. ramana_l_v (3 Posts)
  68. cq.yangyu@gmail.com (1 Post)
  69. siberian (1 Post)
  70. Tommi (4 Posts)
  71. rdblyth (2 Posts)
  72. devtig (3 Posts)
  73. markmansour (1 Post)
  74. dhiren.lodhia (1 Post)
  75. slamhan (1 Post)
  76. panter4 (1 Post)
  77. Korbin (2 Posts)
  78. istetska (1 Post)
  79. ian.young (1 Post)
  80. sebterzi (1 Post)
  81. ucoxk (1 Post)
  82. prakashr (1 Post)
  83. danilo.pederiva (1 Post)
  84. --miCZar-- (2 Posts)
  85. zozofoz (1 Post)
  86. spydercavern (1 Post)
  87. tvelykyy (1 Post)
  88. leorossi (3 Posts)
  89. revertTS (1 Post)
  90. joxzaren (1 Post)
  91. leduc (1 Post)
  92. deepthi_r (1 Post)
  93. qiankun (1 Post)
  94. Mr.Solomon (2 Posts)
  95. agony (1 Post)