1chiban
5 Dec 2011, 7:07 AM
Hi guys,
I need to populate a combobox with distinct values from a store. So I found this method, collect which should return unique values from a provided data index inside a store. But it looks like it's not returning anything when i try to use it.
var AddressStore = Ext.create('Ext.app.Stores.Addresses');
console.log(AddressStore.collect('district'));
var DistrictStore = Ext.create('Ext.data.SimpleStore', {
fields:[{name: 'district', type: 'string'}],
data: EnderecoStore.collect('district')
When i click on the combobox there are no values, it's all blank. I guess I could do it on server side but it would give much more work. The attribute i want it's just a field in my object. So when i try to send the JSON data from the server, it gives me an array like this {"DistrictList": ["District1","District2","District3","District4","District5","District6","District7","District8","District9","District10","District11","District12","District13","District14","District15","District16","District17","District18"]}.
Using this approach i had to create a store in a different way like :
Ext.define('Ext.app.Stores.Districts', {
extend: 'Ext.data.Store',
fields:[
{name:'district', type:'string'}
],
proxy: {
type: 'ajax',
url : '/App/Addresses/Districts',
reader: {
type: 'json',
root: 'DistrictList'
}
},
autoLoad: true
});
Using the collect method it would make it much easier but i haven't managed to make it work yet 8-|
I need to populate a combobox with distinct values from a store. So I found this method, collect which should return unique values from a provided data index inside a store. But it looks like it's not returning anything when i try to use it.
var AddressStore = Ext.create('Ext.app.Stores.Addresses');
console.log(AddressStore.collect('district'));
var DistrictStore = Ext.create('Ext.data.SimpleStore', {
fields:[{name: 'district', type: 'string'}],
data: EnderecoStore.collect('district')
When i click on the combobox there are no values, it's all blank. I guess I could do it on server side but it would give much more work. The attribute i want it's just a field in my object. So when i try to send the JSON data from the server, it gives me an array like this {"DistrictList": ["District1","District2","District3","District4","District5","District6","District7","District8","District9","District10","District11","District12","District13","District14","District15","District16","District17","District18"]}.
Using this approach i had to create a store in a different way like :
Ext.define('Ext.app.Stores.Districts', {
extend: 'Ext.data.Store',
fields:[
{name:'district', type:'string'}
],
proxy: {
type: 'ajax',
url : '/App/Addresses/Districts',
reader: {
type: 'json',
root: 'DistrictList'
}
},
autoLoad: true
});
Using the collect method it would make it much easier but i haven't managed to make it work yet 8-|