PDA

View Full Version : [ACC] ComboBox prepareData reference pass to data view



jay@moduscreate.com
12 Nov 2008, 2:10 PM
It seems we can pass an item selector for the dataview for a given combo box, but cannot override the prepare data method. Ideally, there should probably be a 'dataviewcfg' or 'viewcfg' object that we pass instead of having them inline.




#line 71
this.view = new Ext.DataView({
applyTo: this.innerList,
tpl: this.tpl,
singleSelect: true,
selectedClass: this.selectedClass,
prepareData : this.prepareData || null, //<<--- addition
itemSelector: this.itemSelector || '.' + cls + '-item'
});




I can now easily have an image based dataview for a drop down box like in the examples for data view ;)

Condor
12 Nov 2008, 11:41 PM
Does the 'null' really work?

Wouldn't it be better to use:

this.view = new Ext.DataView({
applyTo: this.innerList,
tpl: this.tpl,
singleSelect: true,
selectedClass: this.selectedClass,
prepareData : this.prepareData || Ext.DataView.prototype.prepareData,
itemSelector: this.itemSelector || '.' + cls + '-item'
});
or

this.view = new Ext.DataView({
applyTo: this.innerList,
tpl: this.tpl,
singleSelect: true,
selectedClass: this.selectedClass,
itemSelector: this.itemSelector || '.' + cls + '-item'
});
if(this.prepareData){
this.view.prepareData = this.prepareData;
}

mystix
13 Nov 2008, 12:48 AM
i'd rather take his other suggestion (and the easy way out):


this.view = new Ext.DataView(Ext.apply({
combo: this, // and while we're at it, let's give the internal DataView a reference to its parent ComboBox
applyTo: this.innerList,
tpl: this.tpl,
singleSelect: true,
selectedClass: this.selectedClass,
itemSelector: this.itemSelector || '.' + cls + '-item'
}, this.viewConfig));

jay@moduscreate.com
13 Nov 2008, 6:07 AM
@condor:
The point of these posts is not to have the dev team take the code verbatim, but rather provide some sort of guidance as to what i'm talking about. That said, I believe they would get the point.

I extended combo to do this at my main gig with great results.

I really like the idea of having a 'veiwConfig' object litteral, and am going to modify this custom extension to accept and apply it.

Animal
15 Nov 2008, 1:59 AM
+1 for the viewConfig config option which is applied to the configuration of the DataView.

jay@moduscreate.com
19 Mar 2009, 3:11 PM
one last friendly bump for visibility :)