Hey, the reason for the new selection is that the selection is based on a JavaScript object which means, you have selected a model object. Reloading via the store creates a new model which is another object. Even the content might be the same, on the JavaScript side, these are two different objects so it falls back to a default selection. What you might want to have is a marge of the objects on reload so you don't have to create a new model and the old selection keeps being around. The stores do not offer such a merged reload currently but it should be not so hard to get that done. I would suggest to create a separate model property somewhere, maybe your application class and update that on store reload. Regards, Martin
Am 31.08.2012 um 23:48 schrieb Rafael Chaves <[email protected]>: > (Recent adopter of Qooxdoo, still struggling with how binding works) > > I have two forms, one for entity A (say, Customer) and another for entity B > (say, Title). > > The customer form is bound to the customer store. The title form is bound to > the title store. The customer form title widget (a list box) is has its own > list controller, which is also bound to the title store. > > When I add a new title (or modify or delete an existing one) , I reload the > title store to as a cheap/heavy handed way to sync things up. Since the > customer form title widget is using the same store, the title select box's > list reflects any changes right away, which is what I wanted to achieve when > I decided both the title widget in the customer form and the title form > would be backed by the same store. > > However, when the title store is reloaded, the existing selection in the > title select box in the customer form is disposed, and the first element > becomes selected, which is wrong. Unless the currently selected title was > deleted, it should remain selected (or the selection should have been > restored to the previously selected title). What is worse is that even > switching to a different customer and coming back to that customer, the 1st > title in the list is still the one selected, so it seems the title property > in the customer model also got modified. > > I wonder if it is a matter of one binding winning against the other. > Anything I can do that will ensure that the existing customer title is > imposed to the select box selection instead of the other way around? > > Here is the code that creates the title widget for the customer form: > > var titleWidget = new qx.ui.form.SelectBox(); > var titleStore = registry.stores['Title']; > var titleController = new qx.data.controller.List(null, titleWidget); > titleStore.bind("model", titleController, "model"); > titleController.setDelegate({bindItem: function(controller, item, index) { > controller.bindProperty("values.name", "label", null, item, index); > controller.bindProperty("uri", "model", null, item, index); > }}); > form.add(titleWidget,'Title', null, 'title'); > > Cheers, > > Rafael > > > > > -- > View this message in context: > http://qooxdoo.678.n2.nabble.com/select-box-selection-lost-when-store-backing-list-is-reloaded-tp7581191.html > Sent from the qooxdoo mailing list archive at Nabble.com. > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > qooxdoo-devel mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ qooxdoo-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
