最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Extjs - combobox Submit value - Stack Overflow

programmeradmin0浏览0评论


Before ill ask my question 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 bo 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 bo 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:
/ 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.


Before ill ask my question 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 bo 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 bo 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./ 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.

Share Improve this question edited Mar 25, 2011 at 6:15 fatnjazzy asked Mar 24, 2011 at 6:17 fatnjazzyfatnjazzy 6,15212 gold badges59 silver badges85 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

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 bo box?When you use hiddenValue, you need to make use of hiddenName. hiddenValue just sets the default value for the bo. 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 bo box from:

 boObject.getValue()

Another possible reason why your form.getForm.getValues() do not give the bo'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)

  1. 暂无评论