PDA

View Full Version : Chosing proxy and parameters when using Combobox



daniele.testa
19 Feb 2013, 8:17 AM
I am having a combobox in one of my forms.

I can select what "store" to use for populating the data, but how do I choose what "proxy" to use and how do I specify what parameters to send?

This is the code I am using for building the combobox. As you can see, I am specifying to use the "Disks" store. I want to also specify what extra parameters to send to the store here, like "id=100" and what "proxy" to use when making the API-call. Seems it is using the "read" proxy by default.

{
fieldLabel: 'Device',
xtype: 'combobox',

editable: false,
disableKeyFilter: true,

store: 'Disks',
valueField: 'device',
displayField: 'path',


listeners: {
beforeload: function() {
console.log("test");
}
},

emptyText: '',
name: 'device'
}

Here is the code that specifies the store:

proxy: {
type: 'ajax',
method: 'GET',
//url: '/api-admin/hosts/list',
api: {
create: '/api-admin/disks/add',
read: '/api-admin/disks/list',
update: '/api-admin/disks/edit',
destroy: '/api-admin/disks/delete',
clone: '/api-admin/disks/clone'
},


reader: {
type: 'json',
root: 'data',
totalProperty: 'total',
successProperty: 'success',
messageProperty: 'message'
}
}

As seen above, I have several "proxies" for the store, like "read", "update", "clone" etc.

How do I specify which one of these "proxies" to use for the combobox-call and what extra parameters to send to the URL the "proxy" specifies?

scottmartin
19 Feb 2013, 1:27 PM
You might be better severed to use an AJAX call based on your selection. You can use
params : { property: value } to send a parameter.

A combo is always going to read to populate the combo list. The other actions are for updating the record.

Scott.

daniele.testa
19 Feb 2013, 6:46 PM
Sorry, I don't understand what you mean? I thought that using a "store" is making a AJAX call automatically?

Do you mean that I should do a AJAX call manually instead of connecting a "store" to the combobox?

If so, do you have an example how to do this? Thanks.