Hi Ryan. Thanks again for your very helpful reply!
> So I'm trying to get to the bottom of what it is you are attempting to do here. From the sound of it, you have something like a textbox that the user can enter text into, and then you filter the data in the store? I'm having a hard time understanding why the viewmodel would need to know about the view at all?
Yes. Good question. It doesn't, it is just me not letting go of MVC controller mentality yet! Lol. Your reply helped change my mindset.
> If you are going to stay "pure" what I would recommend is doing it "old school" and having a listener for the searchText fire an event to the grid which would apply your filter purely through the UI.
Yes, I took that route and handled the whole thing in the view interactions, no need for viewmodel to know at all now.
This did raise one further question though... usually in ExtJS I would add my listeners in the initComponent() on the view:
initComponent: function(){
this.callParent(arguments);
// Add listeners or do stuff now that the component is created
}
I notice with GluJS that at the place I would add the listeners, the ExtJS component is not yet created. That's ok, I used an afterrender listener to the same effect in this case. My question is, is there a "hook" event on the view that once can listen for that is fired after Glu has finished doing everything it does? I was imagining a standard Glu way rather than relying on the appropriate Ext events. Just curious.
> Now, if there is some business logic that you have to do, what I've done before is bind a property on the UI to the viewmodel and then setup a listener for change on the ui which would then fire the event for me. So it would be something like ui -> viewmodel -> viewmodel changes some ui bound property -> ui picks up a change to that property -> ui fires event to other ui components as necessary.
For completeness and my learning, I had a look at this and understand everything except "setup a listener for change on the ui". Is there a Glu way of adding that listener? I tried various things but nothing seemed to work.
So, if the viewmodel has a "mydata" property whose value gets changed by some other process, and in my view I do this:
glu.defView('App.glu.UserSearch', {
xtype : 'form',
mydata : '@{mydata}',
items : [
// items config here
],
// etc
});
How do I add the listener to the view mydata property?
>I hope that helps...
Yes, indeed!
Thanks,
Murray