1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| function multiSelect(select,options,add){
Ext.QuickTips.init();
// turn on validation errors beside the field globally
Ext.form.Field.prototype.msgTarget = 'side';
function replace(expr,a,b) {
var i=0
while (i!=-1) {
i=expr.indexOf(a,i);
if (i>=0) {
expr=expr.substring(0,i)+b+expr.substring(i+a.length);
i+=b.length;
}
}
return expr
}
var multiS, multiSvalue;
var o=new Array();
for (var j =0; j <options.length; j++){
value=options[j].split("*");
name=replace(value[0],"^"," ");
o[j]=[value[1],name];
}
if (add==1) o[j]=[select,'Autre...'];
var ds = new Ext.data.SimpleStore({
fields:['value', 'name'],
data:o
});
var config = {
store:ds,
valueField:'value',
displayField:'name',
triggerAction:'all',
mode:'local',
emptyText:'Tous'
};
multiSvalue = new Ext.form.TextField({
fieldLabel:'Value',
readOnly:false
}),
multiS = new Ext.ux.Andrie.Select(Ext.applyIf({
fieldLabel:'',
multiSelect:true,
minLength:0,
history:true
}, config))
multiS.on('change', function(){get_value(this,multiSvalue,select);}, multiS);
multiS.render(select+'Select');
multiSvalue.render(select+'Value');
} |
Partager