extjs4 - Extjs 4 Store - disallow to add duplicates? -


i have store not connected server. store attached grid , add records in various places in app. is possible not allow add records exists? using idproperty not working (propably because store not connected server?). got this:

ext.define('gsip_plany.grid.store.parcelstore',{     extend: 'ext.data.store',     model: 'gsip_plany.grid.model.parcelmodel',     listeners:{         add:function(store, records, index, eopts) {                     (var in records) {                 var idx = store.findexact('name', records[i].get('name'));                 if ( idx != -1 && idx < index) {                     store.remove(records[i]);                 }             }         }     } }); 

the above code checks if there similar record inserted earlier , if yes, removes new record. problem have remove event handlers attached store, fired in above code, causing removal of record (based on name) in other places of app. want not store records exists. beforeadd event great there no such event.

and model definition:

      ext.define('gsip_plany.grid.model.parcelmodel',{         extend: 'ext.data.model',         fields: ['id', 'name', 'tract', 'mapsheet', 'district', 'buildingnumber', 'streets', 'place'],         idproperty:'name'     });  

the idproperty not working can add many records same name want. ideas?

ext.data.store has suspendevents() , resumeevents() methods (inherited ext.util.observable mixin), let omit triggering of remove event.


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -