admin管理员组

文章数量:1325236

I got a extjs 4 bobox within a form bound to a model. I am binding data from grid to bo using form.loadRecord(record). The bobox is showing the valueField ing from the model assigned to the form instead of the displayField. The store of the bobox is preloaded. How can I achieve that the bobox shows the displayValue loading a record in the form?

        {xtype:'bobox',
        fieldLabel: 'category',
        name: 'categorySelId',
        store: 'Categories',
        queryMode: 'local',
        displayField: 'label',
        valueField: 'id',
        anchor:'96%',
        loadMask: true,
        typeAhead: true,
        forceselection: true,
        valueNotFoundText: 'Nothing found'}

The store is already used in the grid to show the column category

        { header: 'Category', dataIndex: 'categorySelectedId', flex:5,
            renderer: function(value,metaData,record) {
                if(value) {
                    var Categories = Ext.getStore('Categories');
                    var catRecord = Categories.findRecord('id', value);
                    return catRecord ? catRecord.get('label'): record.get('categorySelected');
                } else return "";
            }
        },

Thx for your help!

I got a extjs 4 bobox within a form bound to a model. I am binding data from grid to bo using form.loadRecord(record). The bobox is showing the valueField ing from the model assigned to the form instead of the displayField. The store of the bobox is preloaded. How can I achieve that the bobox shows the displayValue loading a record in the form?

        {xtype:'bobox',
        fieldLabel: 'category',
        name: 'categorySelId',
        store: 'Categories',
        queryMode: 'local',
        displayField: 'label',
        valueField: 'id',
        anchor:'96%',
        loadMask: true,
        typeAhead: true,
        forceselection: true,
        valueNotFoundText: 'Nothing found'}

The store is already used in the grid to show the column category

        { header: 'Category', dataIndex: 'categorySelectedId', flex:5,
            renderer: function(value,metaData,record) {
                if(value) {
                    var Categories = Ext.getStore('Categories');
                    var catRecord = Categories.findRecord('id', value);
                    return catRecord ? catRecord.get('label'): record.get('categorySelected');
                } else return "";
            }
        },

Thx for your help!

Share Improve this question edited May 2, 2012 at 1:16 Manuel asked May 1, 2012 at 21:21 ManuelManuel 9,55215 gold badges75 silver badges118 bronze badges 5
  • Are you sure the store is loaded before you load the record to the bobox? – sha Commented May 2, 2012 at 0:52
  • Yes, I'm sure. I'm using it already in the grid column renderer to show the category label. See source edited post – Manuel Commented May 2, 2012 at 1:15
  • That doesn't prove anything actually. What is the relationship between your grid and a form with bo? – sha Commented May 2, 2012 at 2:08
  • grid on douple click handler: ... var selection = this.getArticleList().getSelectionModel().getSelection()[0]; theForm.loadRecord(selection); ... – Manuel Commented May 2, 2012 at 12:46
  • let us continue this discussion in chat – sha Commented May 2, 2012 at 12:50
Add a ment  | 

1 Answer 1

Reset to default 5

The problem was that I have not had configured the correct types in the model. Setting the right type in the model solved the problem. Thx sha for helping!

本文标签: javascriptExtJS 4 combobox shows valueField instead of displayField on form bindStack Overflow