geoext / geoext2

GeoExt 2 — JavaScript Toolkit for Rich Web Mapping Applications
http://geoext.github.io/geoext2/
Other
142 stars 106 forks source link

PrintProviderField broken for text boxes #363

Closed geographika closed 8 years ago

geographika commented 8 years ago

In https://github.com/geoext/geoext2/blob/master/src/GeoExt/plugins/PrintProviderField.js the onFieldChange accepts 2 arguments.

When a textbox is used the change event passes in 3 arguments.

{
    xtype: "textfield",
    name: "mapTitle", // printProvider.customParams.mapTitle
    fieldLabel: "Map Title",
    plugins: new GeoExt.plugins.PrintProviderField({
    printProvider: printProvider
})

me.fireEvent('change', me, newVal, oldVal);

This means the records parameter has the new value of the textbox as a string, and as it is not an array it is set to the record value.

As record is then always evaluates to true the printProvider.customParams[field.name] = value; is never called.

I guess a workaround could be to check if records is a string?

    onFieldChange: function(field, records) {
        var record;
        if (Ext.isArray(records)) {
            record = records[0];
        } else {
            record = records; // set to string of textbox
        }
        var printProvider = this.printProvider || field.ownerCt.printProvider;
        var value = field.getValue();
        this._updating = true;
        if(record) {
            switch(field.store) {
                case printProvider.layouts:
                    printProvider.setLayout(record);
                    break;
                case printProvider.dpis:
                    printProvider.setDpi(record);
                    break;
                case printProvider.outputFormats:
                    printProvider.setOutputFormat(record);
                default:
                // no op
            }
        } else {
            // never called
            printProvider.customParams[field.name] = value;
        }
        delete this._updating;
    }
marcjansen commented 8 years ago

Do you think ypu can create a PR?

chrismayer commented 8 years ago

Closed by #364