Results 1 to 3 of 3

Thread: How to transform grid info to comboBox

  1. #1

    Question How to transform grid info to comboBox

    Hi,guys!

    I need to click on line in grid and show info into the Formpanel,the example writing by itself I have learned.However,I still don't know how to take it between gird and comboBox.For example,When the grid info below header sex is man,how to show it on comboBox in Formpanel when I click.Thanks

  2. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,791

    Default

    Code:
    new Ext.grid.GridPanel({
        autoExpandColumn: '0',
        height: 200,
        renderTo: Ext.getBody(),
        width: 400,
        columns: [
            {dataIndex: 'name', header: 'Name'},
            {
                dataIndex: 'sex',
                header: 'Sex',
                renderer: function(val) {
                    return val === 'M' ? 'Male' : 'Female';
                }
            },
            {dataIndex: 'age', header: 'Age'}
        ],
        selModel: new Ext.grid.RowSelectionModel({
            singleSelect: true,
            listeners: {
                rowselect: function(selModel, index, record) {
                    // Equivalent to calling setValue() on each field
                    formPanel.getForm().loadRecord(record)
                }
            }
        }),
        store: new Ext.data.ArrayStore({
            fields: ['name', 'sex', 'age'],
            data: [
                ['Tom', 'M', 12],
                ['Sam', 'F', 24],
                ['Cat', 'F', 36]
            ]
        })
    });
    
    var formPanel = new Ext.form.FormPanel({
        height: 200,
        renderTo: Ext.getBody(),
        width: 400,
        items: [
            {fieldLabel: 'Name', name: 'name', xtype: 'textfield'},
            {
                editable: false,
                fieldLabel: 'Sex',
                forceSelection: true,
                name: 'sex',
                store: [['M', 'Male'], ['F', 'Female']],
                triggerAction: 'all',
                xtype: 'combo'
            },
            {fieldLabel: 'Age', name: 'age', xtype: 'numberfield'}
        ]
    });

  3. #3

    Default Thanks

    Thank strike's answer.The key is name must match,I learn from your code.Thank you again

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •