Display combo box when checkbox is checked - Extjs

user2747797

I have setup a checkbox and a combobox and I am trying to set up a functionality - when a user checks the checkbox the combobox has to appear. I am new to extjs and I am having issues setting up the function for this functionality.

Ext.onReady(function() {

var tests = [
    ['Test1'],
    ['Test3'],
    ['Test2']
];
Ext.define('Testfile.model.Test', {
    extend: 'Ext.data.Model',
    fields: ['test']
});
var testsStore = new Ext.data.Store({
    model: 'Testfile.model.Test',
    proxy: {
        type: 'memory',
        reader: {
            type: 'array'
        }
    },
    data: tests
});
var form = Ext.create('Ext.form.Panel', {
    renderTo: document.body,
    bodyPadding: 10,
    width: 550,
    style: 'margin:16px',
    height: 300,
    title: 'Testing example',
    items: [{

          xtype: 'checkbox',
          name: 'system',
          boxLabel: 'Production (PACTV)',
          iputValue: 'production',

        listeners: {
            check: function (checkbox, isChecked) {
                    var sample = Ext.getCmp('secondComboID');
                }

        }
    }, {
        xtype: 'combobox'
        fieldLabel: 'Select Test',
        id: 'secondComboID',
        store: testsStore,
        valueField: 'id',
        displayField: 'test',
        typeAhead: true,
        forceSelection: true,
        allowBlank: false,
        editable: true,
        triggerAction: 'all',
        lastQuery: ''
    }]
});
Ext.getBody().add(me.form);

})

Can someone please suggest a fix to the script?

existdissolve

I would use the change event: http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.form.field.Checkbox-event-change

listeners: {
    change: function(checkbox, newValue, oldValue, eOpts) {
        var combo = checkbox.up('form').down('combobox');
        if (newValue) {
            combo.show();
        } else {
            combo.hide();
        }
    }
}

Also, please notice the use of the hierarchy navigation methods up() and down(). Using these (or other related methods) to find the component is much more preferable than using hard-coded component Ids.

Here's a working example of your code: https://fiddle.sencha.com/#fiddle/ua

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

display button when checkbox is checked

From Dev

How to display html as text inside EXTJS combo box

From Dev

Move checkbox label when box is checked

From Dev

Display specific Column when checkbox is checked

From Dev

Display a list only when a checkbox is checked

From Dev

textbox display needed when checkbox checked

From Dev

Extjs how to capture when the checkbox is checked or unchecked in xtype: 'checkcolumn'

From Dev

Display Label and Progressbar into combo box

From Dev

ExtJs 3.4 : Set tool tip for combo box

From Dev

Dynamic store not loading data in combo box extjs

From Dev

Extjs how to add close icon to the combo box

From Dev

ExtJs 3.4 : Set tool tip for combo box

From Dev

dynamically change the combo box store in extjs

From Dev

How to not display none when checkbox already checked in filter vanilla javascript?

From Dev

How can I display text in checkbox when "if (is checked = true)"

From Dev

Extjs how to remove and undo list items from extjs combo box

From Dev

CheckboxSelectionModel Grid in ExtJs : Cannot select check boxes in a grid panel, all rows will be checked when selecting the header checkbox

From Dev

Get and display checked checkbox index

From Dev

display a bootstrap modal if checkbox is checked

From Dev

Display error if no checkbox is checked in checkbox group

From Dev

Display error if no checkbox is checked in checkbox group

From Dev

Display a 'div' box only when a specific checkbox is selected

From Dev

Combo box will not display values from MySQL

From Dev

Property "RowSource" Fails to Display on Combo Box

From Dev

How to display bootstrap select combo box in datatable?

From Dev

How can I display datatable datetime column as date in Combo Box when using concatenated string?

From Dev

Live Search Combo Box Isn't Working ExtJS 4.2.1

From Dev

ExtJS/MODx CMP: grid edits not saving to db, combo box not displaying

From Dev

Live Search Combo Box Isn't Working ExtJS 4.2.1

Related Related

  1. 1

    display button when checkbox is checked

  2. 2

    How to display html as text inside EXTJS combo box

  3. 3

    Move checkbox label when box is checked

  4. 4

    Display specific Column when checkbox is checked

  5. 5

    Display a list only when a checkbox is checked

  6. 6

    textbox display needed when checkbox checked

  7. 7

    Extjs how to capture when the checkbox is checked or unchecked in xtype: 'checkcolumn'

  8. 8

    Display Label and Progressbar into combo box

  9. 9

    ExtJs 3.4 : Set tool tip for combo box

  10. 10

    Dynamic store not loading data in combo box extjs

  11. 11

    Extjs how to add close icon to the combo box

  12. 12

    ExtJs 3.4 : Set tool tip for combo box

  13. 13

    dynamically change the combo box store in extjs

  14. 14

    How to not display none when checkbox already checked in filter vanilla javascript?

  15. 15

    How can I display text in checkbox when "if (is checked = true)"

  16. 16

    Extjs how to remove and undo list items from extjs combo box

  17. 17

    CheckboxSelectionModel Grid in ExtJs : Cannot select check boxes in a grid panel, all rows will be checked when selecting the header checkbox

  18. 18

    Get and display checked checkbox index

  19. 19

    display a bootstrap modal if checkbox is checked

  20. 20

    Display error if no checkbox is checked in checkbox group

  21. 21

    Display error if no checkbox is checked in checkbox group

  22. 22

    Display a 'div' box only when a specific checkbox is selected

  23. 23

    Combo box will not display values from MySQL

  24. 24

    Property "RowSource" Fails to Display on Combo Box

  25. 25

    How to display bootstrap select combo box in datatable?

  26. 26

    How can I display datatable datetime column as date in Combo Box when using concatenated string?

  27. 27

    Live Search Combo Box Isn't Working ExtJS 4.2.1

  28. 28

    ExtJS/MODx CMP: grid edits not saving to db, combo box not displaying

  29. 29

    Live Search Combo Box Isn't Working ExtJS 4.2.1

HotTag

Archive