ExtJS – store and combobox snipplet

By 19. Oktober 2012 general No Comments

search and get Store reference:

var store = Ext.data.StoreManager.lookup('YearStore');

or

var store = Ext.ComponentQuery.query('combobox[name=vonY]')[0].getStore();

 

Fill combobox with the current and the last two year using a loop:
 

var today = new Date();
var year = today.getFullYear();
var newyear = year - 2;
var arr = new Array();
var i = 0;

 

while (year >= newyear) {
  store.add({year: newyear});
  newyear++;
  i++;
}

 

Store:

 

Ext.define('PCC.store.YearStore', {
extend : 'Ext.data.Store',
alias: 'widget.yearStore',
fields : ['year'],
autoLoad: false
});

Leave a Reply