marimuthup
15 Jul 2007, 1:12 PM
Hi,
I am new to YUI-ext.
I liked these great widgets. I waana to use combobox for loading data remote thru JSON Reader.
I am using two combos first for loading the data from remote, second combo to load the data localy ( Extracted from the example)
First Combobox using the JSONStore is not able to load the data, though it gets the data from the server thru the url.
Second combo is loading the data locally
Firebug shows the request and the data return
POST http://localhost:8080/YahooUITest/GetCallCenter (62ms)ext-base.js (line 12)
ParamsHeadersPostResponse
Response Headers
Request Headers
{directions:[{name:"South",id:1},{name:"North",id:2},{name:"East",id:3},{name:"west",id:4},{name:"Middle"
,id:5}]}
I am for sure, I am missing some sequence.
var ResizableExample = {
init : function(){
var basic = new Ext.Resizable('basic', {
width: 200,
height: 100,
minWidth:100,
minHeight:50
});
var read = new Ext.data.JsonReader({
root: 'directions',
id: 'name'},
[
{name: 'name', mapping: 'name'},
{name: 'id', mapping: 'id'}
]);
var store1 = new Ext.data.JsonStore(
{
url: '/YahooUITest/GetCallCenter',
fields:['name','id'],
reader: read,
baseParams: {
type: 'name'
}
});
store1.load();
//mgr.on("update", transformCombo2);
var combo = new Ext.form.ComboBox({
store: store1,
displayField:'name',
valueField:'id',
typeAhead: true,
loadingText: 'Searching...',
mode: 'remote',
triggerAction: 'all',
emptyText:'Select a local state...',
selectOnFocus:true,
resizable:true,
forceSelection:true
});
combo.applyTo('local-states');
combo.on('select', combo1SelectionChanged);
// simple array store
var store2 = new Ext.data.SimpleStore({
fields: ['abbr', 'state'],
data : Ext.exampledata.states // from states.js
});
var combo2 = new Ext.form.ComboBox({
store: store2,
displayField:'state',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Select a state...',
selectOnFocus:true,
resizable:true
});
combo2.applyTo('states-abr');
combo2.on('select', combo2SelectionChanged);
}
};
function combo1SelectionChanged(record,index){
alert("Combo1 Selected " + record +" index " + index);
}
function combo2SelectionChanged(record,index){
alert("Combo2 Selected " + record +" index " + index);
}
Ext.EventManager.onDocumentReady(ResizableExample.init, ResizableExample, true);
I am new to YUI-ext.
I liked these great widgets. I waana to use combobox for loading data remote thru JSON Reader.
I am using two combos first for loading the data from remote, second combo to load the data localy ( Extracted from the example)
First Combobox using the JSONStore is not able to load the data, though it gets the data from the server thru the url.
Second combo is loading the data locally
Firebug shows the request and the data return
POST http://localhost:8080/YahooUITest/GetCallCenter (62ms)ext-base.js (line 12)
ParamsHeadersPostResponse
Response Headers
Request Headers
{directions:[{name:"South",id:1},{name:"North",id:2},{name:"East",id:3},{name:"west",id:4},{name:"Middle"
,id:5}]}
I am for sure, I am missing some sequence.
var ResizableExample = {
init : function(){
var basic = new Ext.Resizable('basic', {
width: 200,
height: 100,
minWidth:100,
minHeight:50
});
var read = new Ext.data.JsonReader({
root: 'directions',
id: 'name'},
[
{name: 'name', mapping: 'name'},
{name: 'id', mapping: 'id'}
]);
var store1 = new Ext.data.JsonStore(
{
url: '/YahooUITest/GetCallCenter',
fields:['name','id'],
reader: read,
baseParams: {
type: 'name'
}
});
store1.load();
//mgr.on("update", transformCombo2);
var combo = new Ext.form.ComboBox({
store: store1,
displayField:'name',
valueField:'id',
typeAhead: true,
loadingText: 'Searching...',
mode: 'remote',
triggerAction: 'all',
emptyText:'Select a local state...',
selectOnFocus:true,
resizable:true,
forceSelection:true
});
combo.applyTo('local-states');
combo.on('select', combo1SelectionChanged);
// simple array store
var store2 = new Ext.data.SimpleStore({
fields: ['abbr', 'state'],
data : Ext.exampledata.states // from states.js
});
var combo2 = new Ext.form.ComboBox({
store: store2,
displayField:'state',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Select a state...',
selectOnFocus:true,
resizable:true
});
combo2.applyTo('states-abr');
combo2.on('select', combo2SelectionChanged);
}
};
function combo1SelectionChanged(record,index){
alert("Combo1 Selected " + record +" index " + index);
}
function combo2SelectionChanged(record,index){
alert("Combo2 Selected " + record +" index " + index);
}
Ext.EventManager.onDocumentReady(ResizableExample.init, ResizableExample, true);