[GIS] Call GeoExt action by click ExtJs button

geoextopenlayers-2

I have a problem.
I have a ExtJs button and want to call anyone GeoExt action. For example this

{xtype:'tbbutton',
                        cls: 'x-btn-icon',
                        id: 'testbutton',
                        tooltip: "Рисовать",
                        icon: url_servlet+'externals/gxp/src/theme/img/silk/delete.png',
                        handler: function(){
                            new GeoExt.Action({
                                text: "max extent",
                                control: new OpenLayers.Control.ZoomToMaxExtent(),
                                map: app.mapPanel.map
                            })
                        }

                      }

But its not work and map not zoom to max extent. So where i can mistake.
In ideal i want to call action from actionColumn's buttons/
I will glad if u help/

Best Answer

A GeoExt Action is already a button, so there is no need to create the ExtJS button as well. Create the GeoExt action and add it to a toolbar.

action = new GeoExt.Action({
    control: new OpenLayers.Control.ZoomToMaxExtent(),
    map: map,
    text: "max extent",
    tooltip: "zoom to max extent"
});

http://api.geoext.org/1.1/examples/toolbar.html

If you just want to have a button on a form to zoom to the max extent of the map, then call the zoomToMaxExtent function directly in the handler:

 {
    xtype:'tbbutton',
    cls: 'x-btn-icon',
    id: 'testbutton',
    tooltip: "Рисовать",
    icon: url_servlet+'externals/gxp/src/theme/img/silk/delete.png',
    handler: function(){
        app.mapPanel.map.zoomToMaxExtent();
        })
    }
 }
Related Question