ComboBox testing 2

Using ExtJS 3.0

by b_long

HTML

<script src="https://getfirebug.com/firebug-lite-debug.js"></script>
<!doctype html>
<html>
    
    <head>
        <title>MessageBox</title>
        <script type="text/javascript" src="http://extjs.cachefly.net/ext-3.0.0/adapter/ext/ext-base.js"></script>
        <script type="text/javascript" src="http://extjs.cachefly.net/ext-3.0.0/ext-all.js"></script>
        <link href="http://extjs.cachefly.net/ext-3.0.0/resources/css/ext-all.css" rel="stylesheet" type="text/css" />
    </head>
    
    <body>
        <div id="toolbar" />
        <div id="btn" />
    </body>

</html>

JavaScript

Ext.onReady(function () {
    console.log("Loaded ExtJS version: " + Ext.version);
    
    var UpgradedComboBox = Ext.extend(Ext.form.ComboBox, {
        listeners: {
                /**
                 * Allows us to compare a newly selected value vs. an old value.
                 *
                 *
                 * This is our own modification since Ext's ComboBox "change" event doesn't work properly.
                 *
                 * See here: http://www.sencha.com/forum/showthread.php?4913-Ext.form.ComboBox-change-Event-doesn-t-work/page2
                 * Quote: "there are indeed horrible bugs in the event system"
                 *
                 *
                 * @param {type} comboBox
                 * @param {type} record
                 * @param {type} index
                 * @returns {undefined}
                 */
                beforeselect: function(comboBox, record, index) {
                    logger.info("beforeselect fired");
                    comboBox.previousValue = comboBox.getValue();
                }
            }
        });

		var comboStore = new Ext.data.ArrayStore({
            data: [
                // A blank record first
                ["Default", "DEFAULT"],
                ["Option 1", "OPTION-1"],
                ["Option 2", "OPTION-2"]
            ],
            fields: [
                'view',
                'value'
            ]
        });

        var displayField = comboStore.fields.keys[0];
        var valueField = comboStore.fields.keys[1];

        var comboBoxToTest = new UpgradedComboBox({
			displayField: displayField,
			editable: false,
			fieldLabel: "Combo label",
			forceSelection: true,
			listeners: {
//                'change': function(comboBox, newVal, oldVal) {
//					logger.info("comboBox has newVal: '" + newVal + "' and oldVal: '" + oldVal + "'");
//                },
				'select': function(comboBox, record, index) {
					logger.info("You've selected: " +...