formula with strange behavior

7 views
Skip to first unread message

mauro larese

unread,
Mar 28, 2014, 3:31:15 PM3/28/14
to gl...@googlegroups.com
this formula is working only one time.
what is wrong with it?

         foundCustomer$:function(){
               if (this.store==null) {
                   found=false;
               } else{
                   found=this.store.getCount()>0;
               }
               return found;
           }

thank you very much
- Mauro

Ryan Smith

unread,
Mar 28, 2014, 4:08:54 PM3/28/14
to gl...@googlegroups.com
In this case, glu doesn't know what you are really looking for.  It can detect when there is a change to the store if you set the store property using something like this.set('store', Ext.create('Ext.data.Store', {})), but when the length of the store changes, there is no event fired that glu can listen to.

In your case, what I would do is setup a listener on the store for when the store is loaded, or the data is changed and then recalculate the formula and set the appropriate variable.  Something like this.

init: function(){
    this.store.on('datachanged', function(store){
        this.set('found', store.getCount() > 0)
    }, this)
}

That will allow you to listen to events that have changed on the store and determine when the count changes or anything changes.  Hopefully that helps!

-Ryan


--
You received this message because you are subscribed to the Google Groups "GluJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to glujs+un...@googlegroups.com.
To post to this group, send email to gl...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/glujs/5a0c0405-5fe7-4aec-a072-533d8283b901%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Josh VanderLinden

unread,
Mar 28, 2014, 4:09:26 PM3/28/14
to gl...@googlegroups.com
It looks like the problem is you're not really computing the value using actual properties of your viewmodel. It seems that formulas only update when you change properties using this.set('propertyName', 'value')

--
Reply all
Reply to author
Forward
0 new messages