-
24 Mar 2011 6:31 AM #1
[CLOSED-EXTJSIV-303] Add to Ext.data.Model update/datachanged event
[CLOSED-EXTJSIV-303] Add to Ext.data.Model update/datachanged event
subj
-
31 Mar 2011 10:39 PM #2
We decided not to implement this for 2 reasons:
1) It's not really a common use case to want to listen to an event on a single record, rather you'll want to listen to changes on a group of records.
2) Possible performance implications, records get updated quite a lot, as well as being recreated behind the scenes, which makes it difficult to main the events.Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
19 Jun 2012 11:22 PM #3
too bad
too bad
It's a real usecase for us. No normal workaround either...
-
21 Jun 2012 2:07 PM #4
I do have a workaround for this issue - it's not the prettiest solution in the world, but it does work, at least for me. The basic principle is to use Ext.data.Model#join to fool the record into thinking that your listener class is one of the parent stores for the model record, which will then be notified when that particular record is edited. Although the documentation says that Ext.data.Model.join() expects the parameter to be a Store, you don't actually have to extend the Ext.data.Store class. Instead, you just need to be sure to implement "afterEdit", "afterReject", and "afterCommit" methods on your listener class, and they will be called appropriately by the record. Just be sure to unjoin() when you're done with the listener!
Here's a simple example:
Note that I'm using this with ExtJS 4.1.0 ... I don't know if it will work on other versions or not.Code:Ext.define('User', { extend: 'Ext.data.Model', fields: ['id', 'name'] }); Ext.define('Listener', { constructor: function(record) { record.join(this); }, afterEdit: function(record) { console.log('edit'); }, afterReject: function(record) { console.log('reject'); }, afterCommit: function(record) { console.log('commit'); } }); var user = Ext.create('User', { id: 1, name: 'John' }); var listener = Ext.create('Listener', user); user.set('name', 'Joe');
-
22 Nov 2012 3:10 AM #5
Maybe it make sense to add configuration item for making model observable?
So if it is needed model will have events
Thank you for reporting this bug. We will make it our priority to review this report.
Similar Threads
-
[FIXED-EXTJSIV-212] Ext.data.Store.sync() does not update 'id' of phantom records
By madrabaz in forum Ext:BugsReplies: 5Last Post: 6 Apr 2012, 1:38 AM -
[CLOSED-EXTJSIV-538]Model instance still phantom after successful save and/or commit
By daanlib in forum Ext:BugsReplies: 9Last Post: 5 Sep 2011, 4:13 PM -
Store does not fire "datachanged" event when data is updated
By tfrugia in forum Sencha Touch 1.x: DiscussionReplies: 1Last Post: 17 Dec 2010, 12:40 PM -
# [CLOSED-471723] Why update event is handler many times on Ext.data.Store ?
By rimbaudsolaris in forum Ext 3.x: Help & DiscussionReplies: 13Last Post: 2 Jun 2010, 11:35 AM -
[2.0][CLOSED] grid.getSelectionModel().getCount() unchanged after datachanged event
By digeomel in forum Ext 2.x: BugsReplies: 2Last Post: 9 Jan 2008, 6:22 AM


Reply With Quote