ComboBox.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /**
  2. * @author Steven Roussey
  3. *
  4. * @ usage:
  5. * {
  6. * xtype:'combo',
  7. * store:['Reader','Participant','Moderator','SuperUser']
  8. * }
  9. * Or
  10. * {
  11. * xtype:'combo',
  12. * store:[['r','Reader'],['p','Participant'],['m','Moderator'],['s','SuperUser']]
  13. * }
  14. */
  15. Ext.ux.ComboBox = function(config){
  16. if (config.store && typeof config.store !='string' && config.store.length>1)
  17. {
  18. if (typeof config.store[0] !='string' && config.store[0].length>1)
  19. {
  20. config.store = new Ext.data.SimpleStore({
  21. fields: ['value','text'],
  22. data : config.store
  23. });
  24. config.valueField = 'value';
  25. config.displayField = 'text';
  26. }
  27. else
  28. {
  29. var store=[];
  30. for (var i=0,len=config.store.length;i<len;i++)
  31. store[i]=[config.store[i]];
  32. config.store = new Ext.data.SimpleStore({
  33. fields: ['text'],
  34. data : store
  35. });
  36. config.valueField = 'text';
  37. config.displayField = 'text';
  38. }
  39. config.mode = 'local';
  40. }
  41. Ext.ux.ComboBox.superclass.constructor.call(this, config);
  42. }
  43. Ext.extend(Ext.ux.ComboBox,Ext.form.ComboBox,{
  44. });
  45. Ext.reg('combo',Ext.ux.ComboBox);