开发者

Extjs - combobox Submit value

开发者 https://www.devze.com 2023-02-19 04:33 出处:网络
Before ill ask my questi开发者_运维百科on I sould mention that i read every post about this problem.

Before ill ask my questi开发者_运维百科on I sould mention that i read every post about this problem.

I am submitting my extjs form using: form.getForm().getValues() in an independent ajax request.

I cant submit my value (userManager_userId) in a combo to to the server:

       new Ext.form.ComboBox({
            name: 'userManager_userName',
            valueField: 'userManager_userId',
            hiddenValue : 'userManager_userId',//I want to send this ti the server (Integer)
            displayField: 'userManager_userName'
            ....
    )}

The combo providing/submitting its display and not its value.

I should mention that when the for loads, I charge it with data from the server by using a Ext.data.JsonReader

Thanks

Update

So I did a little test for you to see live:

http://fatnjazzy.byethost8.com/ you can view source to see the js source.

Ill post it here when we are done.

Now it is working but the form does not initial its values.


Use hiddenName in place of or in addition to name. This will create a hidden field of that name which will store the value of the current selection's valueField. Also note that the hiddenValue config is for setting the initial value of the hidden field and is not a field name declaration.

Here is an altered ComboBox definition which will submit the value of the selected record's userManager_userId field through a request parameter of userId:

new Ext.form.ComboBox({
    hiddenName: 'userId',
    valueField: 'userManager_userId',
    displayField: 'userManager_userName',
    // ...
});


Do you have hiddenName property set for your combo box?When you use hiddenValue, you need to make use of hiddenName. hiddenValue just sets the default value for the combo. By setting it you will not be able to send the value to the server side.

Update: Since you are using separate Ajax request to submit the form, why are you using hidden field to store the values? you could access the value of the combo box from:

 comboObject.getValue()

Another possible reason why your form.getForm.getValues() do not give the combo's values will be due to having wrong value in valueField. In your case you have userManager_userId. Is that your underlying data value name to bound to the ComboBox? Here is my example:

store: new Ext.data.JsonStore({
    fields:['item','value'],                            
    data: [
            {item:'Option 1',value: 'OP1'},
            {item:'Option 2',value: 'OP2'},
            {item:'Option 3',value: 'OP3'}
        ]                   
}),
mode: 'local',
editable: false, 
allowBlank: false,
forceSelection: true,
valueField: 'value',
displayField: 'item',
name:'tt',
id: 'tt'

Here the valueField's value is bound to my store's value field..

0

精彩评论

暂无评论...
验证码 换一张
取 消