PDA

View Full Version : chained combo attempt - not passing variable in post



leester
24 Nov 2009, 2:37 PM
I can't figure out at all what I'm missing here.

In Firebug, the 'POST' only shows the task "COMBO" as it should, but it is not passing anything else. Not even "id_no: " as I'd expect if it were attempting to send a blank variable.

I'm not quite sure if this is even the proper approach for version 3 - or if this has somehow been made more 'obvious' compared to what I'm finding in searches, which for all I know are v2 samples.

I only need two combos, primary and secondary dependent.

The first one loads (remote) as I'd expect it when selected, and fires off the event/post - but only sends the task:COMBO parameter.

What am I doing wrong?

Thanks,
Lee



var formUpdateMulti = new Ext.FormPanel({
title: 'Update Multiple Selected Records',
labelWidth: 75,
// label settings here cascade unless overridden
labelAlign: 'right',
url: 'database.php',
frame: true,
bodyStyle: 'padding:5px 5px 0',
width: 550,
height: 200,
region: 'south',
// uses layout manager for leadslistingwindow
layout: 'column',
// arrange items in columns
items: [{ // CURRENTLY WORKING ON GETTING CHAINED COMBO BOX WORKING
xtype: 'fieldset',
title: 'Assign Leads',
autoHeight: true,
items: [
managerCombo = new Ext.form.ComboBox({
width: 175,
fieldLabel: "Manager",
name: 'manager',
store: ManagersDataStore,
displayField: 'agentDisplayName',
valueField: 'id_no',
hiddenName: 'id_no',
hiddenValue: 'id_no',
mode: 'remote',
triggerAction: 'all',
emptyText: 'Select Manager...',
selectOnFocus: true
}), agentCombo = new Ext.form.ComboBox({
fieldLabel: 'Agent',
hiddenName: 'agent',
store: ComboDataStore,
displayField: 'agentDisplayName',
valueField: 'id_no',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText: 'Select Agent...',
selectOnFocus: true,
width: 175
})

]
}]
}); // end of the formUpdateMulti section
managerCombo.on('select', function () {
agentCombo.reset();
ComboDataStore.proxy = new Ext.data.HttpProxy({
url: 'database.php',
method: 'POST',
params: {
task: "DOWNLINE",
id_no: managerCombo.getValue()
},
});
ComboDataStore.load();
});

leester
25 Nov 2009, 1:25 PM
So after trying every example I can find over the last week... I'm still stumped. (it took me a week to break down and post the above plea for help)

I've made progress, but I'm still stumped.

It appears that the FIRST time I click on the 'secondary' dependent combobox, it loads the datastore (for the first time) using baseParams - and overwrites the filtered store.

Each time after the first click, it works properly.

So... how do I catch that 'first click' on a dependent combo and keep it from overwriting the proper store that's already been generated when the user clicks the primary combobox?


The predefined store: (if it ain't there, it breaks... obviously)


var ComboDataStore = new Ext.data.Store({ // get leads from db into datastore
id: 'ComboDataStore',
autoload: false,
proxy: new Ext.data.HttpProxy({
url: 'database.php',
// File to connect to
method: 'POST'
}),
baseParams: {
task: "COMBO",
},
// this parameter asks for DOWNLINE
reader: new Ext.data.JsonReader({
// we tell the datastore where to get this data from
root: 'results',
totalProperty: 'total',
id: '0'
},
[{
name: 'id_no',
type: 'string',
mapping: 'id_no'
},
{
name: 'last_name',
type: 'string',
mapping: 'last_name'
},
{
name: 'first_name',
type: 'string',
mapping: 'first_name'
},
{
name: 'agentDisplayName',
type: 'string',
mapping: 'agentDisplayName'
},
{
name: 'distcode',
type: 'string',
mapping: 'distode'
}]),
sortInfo: {
field: 'last_name',
direction: "ASC"
}
});

The part of the form where I've got the two combos...


items: [{ // CURRENTLY WORKING ON GETTING CHAINED COMBO BOX WORKING
xtype: 'fieldset',
title: 'Assign Leads',
autoHeight: true,
items: [
managerCombo = new Ext.form.ComboBox({
width: 175,
fieldLabel: "Manager",
name: 'manager',
store: ManagersDataStore,
displayField: 'agentDisplayName',
valueField: 'id_no',
hiddenName: 'id_no',
hiddenValue: 'id_no',
mode: 'remote',
triggerAction: 'all',
emptyText: 'Select Manager...',
selectOnFocus: true
}), agentCombo = new Ext.form.ComboBox({
fieldLabel: 'Agent',
hiddenName: 'agent',
store: ComboDataStore,
displayField: 'agentDisplayName',
valueField: 'id_no',
typeAhead: true,
mode: 'remote',
triggerAction: 'all',
emptyText: 'Select Agent...',
selectOnFocus: true,
width: 175
})

]

and the lil function that could... but only after the first botched pass...


function getDownlineCombo() {
agentCombo.reset();
ComboDataStore.load({params:{id_no:managerCombo.getValue()}});
}

which happens when... (I can see it in Firebug)


managerCombo.on('select', getDownlineCombo);

...but gets 'undone' the first time you click on the agentCombo (secondary)

What am I doing wrong? I read the "Extjs makes hard things easy and vice versa" threads, grabbed JG's ebook, heck, I'm about 8 weeks into Extjs and still in the dark, but don't want to give up.

Links? Hints? Bueller?

Thanks
Lee