ExtJs, komponente u toolbaru panela

dockedItems: [{
        xtype: 'toolbar',
        dock: 'bottom',
        items: [{
            text: 'Fokusiraj na Omišalj',
            handler: function () {
                var me = this,
                    panel = GeoExt.panel.Map.guess(),
                    map = panel.map;
                map.setCenter(new OpenLayers.LonLat(1617951, 5656077), 15);
                //map.zoomToExtent(panel.extent, true);
            }
        }, {
            text: 'Full screen',
            enableToggle: true,
            listeners: {
                click: function () {

                    var me = this,
                        map_panel = Ext.ComponentQuery.query('#main-map-panel')[0],
                        viewport_width = document.documentElement.clientWidth,
                        viewport_height = document.documentElement.clientHeight,
                        default_width = map_panel.default_width,
                        default_height = map_panel.default_height;

                    if (me.pressed == true) {
                        map_panel.setWidth(viewport_width);
                        map_panel.setHeight(viewport_height);
                        me.setText('Vrati na originalne dimenzije');
                        return;
                    }

                    map_panel.setWidth(default_width);
                    map_panel.setHeight(default_height);
                    me.setText('Full screen');
                }
            }
        }]
    }]

 

Client side Save as dialog

Trenutno provjereno radi u Chrome i Firefox preglednicima.

1. u js-u kreiraj Blob objekt koji sadrži podatke koje šalješ klijentu

var data = ['Vrijeme;ChargeCurrent;LoadCurrent;Voltage2013.01.178:34:28;0.24;0.28;13.152013.01.17 09:50:48;0.36;0.22;13.452013.01.17 11:15:54;0.39;0.33;13.69'];
var blob = new Blob([data], {type : 'text/csv'});

2. Kreiraj data uri do Blob objekta

var url = URL.createObjectURL(blob);

3. Kreiraj ili modificiraj anchor

var anchor = document.getElementById('a');
anchor.href = url;
anchor.download = '1.csv'; // Naziv i ekstenzija datoteke

 

Ovako izgleda finalni element

<a id="a" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA
AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
9TXL0Y4OHwAAAABJRU5ErkJggg==" download="red_dot.png">Download red dot</a>