Temat: comboBox - dane pobierane z bazy
// Pobranie listy kategorii z drugiej tabeli
KategoriaDataStore = new Ext.data.Store({
id: 'KategoriaDataStore',
proxy: new Ext.data.HttpProxy({
url: 'db.php',
method: 'POST'
}),
baseParams:{task: "LISTING"},
reader: new Ext.data.JsonReader({
root: 'results',
totalProperty: 'total',
id: 'id'
},[
{name: 'id', type: 'int', mapping: 'id'},
{name: 'name', type: 'string', mapping: 'name'}
]),
sortInfo:{field: 'id', direction: "ASC"}
});
// Pobranie Pierwszej głównej tabeli - jedno pole przetrzymuje tylko id kategorii
TelefonDataStore = new Ext.data.Store({
id: 'TelefonDataStore',
proxy: new Ext.data.HttpProxy({
url: 'db.php', // File to connect to
method: 'POST'
}),
baseParams:{task: "LISTING2"},
reader: new Ext.data.JsonReader({
root: 'results',
totalProperty: 'total',
id: 'id'
},[
{name: 'id', type: 'int', mapping: 'id'},
{name: 'nr_tel', type: 'int', mapping: 'nr_tel'},
{name: 'id_kategoria', type: 'string', mapping: 'id_kategoria'}
]),
sortInfo:{field: 'id', direction: "ASC"}
});
// wyswietlanie całej tabeli
TelefonColumnModel = new Ext.grid.ColumnModel({
defaults:{
sortable: true
},
columns: [{
header: '#',
readOnly: true,
dataIndex: 'id',
width: 50,
hidden: false
},{
header: 'nr tel',
dataIndex: 'nr_tel',
width: 100,
editor: new Ext.form.TextField({
allowBlank: false,
maxLength: 30
})
},
{
header: 'id kategorii',
readOnly: true,
dataIndex: 'id_kategoria',
width: 50,
hidden: true
},{
header: 'Kategoria',
dataIndex: 'id_kategoria',
width: 100,
editor: new Ext.form.ComboBox({
store: KategoriaDataStore,
displayField: 'id_kategoria',
valueField: 'name',
typeAhead: true,
mode: 'remote',
triggerAction: 'all',
selectOnFocus:true
}),
hidden:false
}],
stripeRows:true
});
Dawid Sandylewski edytował(a) ten post dnia 11.03.11 o godzinie 14:02