-
15 Oct 2009 8:21 PM #1
Property grid : dynamic items
Property grid : dynamic items
Hey everyone,
I'm doing a thing at the moment where I would prefer to add properties to a property grid after creation (long story). I found an excellent thread for doing it in Ext 2 (thanks to condor) but had to tweak it (slightly) to get it going in Ext 3.
Turns out it just needed propStore to be removed from Condors original script to be Ext 3 friendly. Seems to be working fine now so I thought I'd share in case it was useful to anyone else...
(apologies if this has already been done, I looked but I couldn't find it anywhere)Code:Ext.override(Ext.grid.PropertyGrid, { setProperty: function(property, value){ this.source[property] = value; var r = this.store.getById(property); if(r){ // update property r.set('value', value); }else{ // add property this.store.add(new Ext.grid.PropertyRecord({name: property, value: value}, property)); } }, removeProperty: function(property){ delete this.source[property]; var r = this.store.getById(property); if(r){ // remove property this.store.remove(r); } } });
-
15 Oct 2009 9:37 PM #2
Hey everyone,
Slight update, this lets you label the property differently from its id in the property grid :
Code:Ext.override(Ext.grid.PropertyGrid, { setProperty: function(property, label, value){ eval('this.propertyNames.'+property+'="'+label+'"'); this.source[property] = value; var r = this.store.getById(property); if(r){ // update property r.set('value', value); }else{ // add property this.store.add(new Ext.grid.PropertyRecord({name: property, value: value}, property)); } }, removeProperty: function(property){ delete this.source[property]; var r = this.store.getById(property); if(r){ // remove property this.store.remove(r); } } });
-
16 Oct 2009 2:58 AM #3Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 40
I've made a feature request for some PropertyGrid enhancements (including this one).
@ultramedia: Don't you know that 'eval' is evil (at least according to jslint)?
And you don't even need it in this case:
Code:Ext.override(Ext.grid.PropertyGrid, { setPropertyName: function(property, name){ this.propertyNames[property] = name; } });
-
16 Oct 2009 3:09 AM #4
That's DR evil. I didn't spend six years in evil medical school to be call mister thank you very much...
But seriously though, thanks for that Condor, it's much better like that
*edit* urk, yeah now that I look at it, mine was nasty ugly. Ah well....
-
2 Dec 2009 3:25 AM #5
Thx for this enhancement
Just watch out using numbers in the label, the eval won't work.


Reply With Quote