[Users] insert code into an icon in tbar
Gery .
gamejihou at hotmail.com
Sat Jun 23 16:38:09 CEST 2012
Hello,
I'm new around the GeoExt great community, I have probably some pretty basic questions and hope some advanced users could help me to solve them. The thing is that I'd like to put the form print (http://api.geoext.org/1.1/examples/print-form.html) as an icon in my top tool bar, I have already the tbar in my map and the form print is there, however I want to put it inside an icon. Attached you can take a look at the map and how it is now with the form print and a printer icon. The code of the form print is as follows:
[CODE]
// The printProvider that connects us to the print service
var printProvider = new GeoExt.data.PrintProvider({
method: "GET", // "POST" recommended for production use
capabilities: printCapabilities, // from the info.json script in the html
customParams: {
mapTitle: "Printing Demo"
}
});
// Our print page. Stores scale, center and rotation and gives us a page
// extent feature that we can add to a layer.
printPage = new GeoExt.data.PrintPage({
printProvider: printProvider
});
// A layer to display the print page extent
var pageLayer = new OpenLayers.Layer.Vector();
pageLayer.addFeatures(printPage.feature);
// The map we want to print
mapPanel = new GeoExt.MapPanel({
region: "center",
map: {
eventListeners: {
// recenter/resize page extent after pan/zoom
"moveend": function(){ printPage.fit(this, {mode: "screen"}); }
}
}
});
// The form with fields controlling the print output
var formPanel = new Ext.form.FormPanel({
region: "west",
width: 150,
bodyStyle: "padding:5px",
labelAlign: "top",
defaults: {anchor: "100%"},
items: [{
xtype: "textarea",
name: "comment",
value: "",
fieldLabel: "Comment",
plugins: new GeoExt.plugins.PrintPageField({
printPage: printPage
})
}, {
xtype: "combo",
store: printProvider.layouts,
displayField: "name",
fieldLabel: "Layout",
typeAhead: true,
mode: "local",
triggerAction: "all",
plugins: new GeoExt.plugins.PrintProviderField({
printProvider: printProvider
})
}, {
xtype: "combo",
store: printProvider.dpis,
displayField: "name",
fieldLabel: "Resolution",
tpl: '<tpl for="."><div class="x-combo-list-item">{name} dpi</div></tpl>',
typeAhead: true,
mode: "local",
triggerAction: "all",
plugins: new GeoExt.plugins.PrintProviderField({
printProvider: printProvider
}),
// the plugin will work even if we modify a combo value
setValue: function(v) {
v = parseInt(v) + " dpi";
Ext.form.ComboBox.prototype.setValue.apply(this, arguments);
}
}, {
xtype: "combo",
store: printProvider.scales,
displayField: "name",
fieldLabel: "Scale",
typeAhead: true,
mode: "local",
triggerAction: "all",
plugins: new GeoExt.plugins.PrintPageField({
printPage: printPage
})
}, {
xtype: "textfield",
name: "rotation",
fieldLabel: "Rotation",
plugins: new GeoExt.plugins.PrintPageField({
printPage: printPage
})
}],
buttons: [{
text: "Create PDF",
handler: function() {
printProvider.print(mapPanel, printPage);
}
}]
[/CODE]
I did a pretty basic code with GeoExt.Action to load a printer icon, here is the code:
[CODE]
action = new GeoExt.Action(
{
control: new OpenLayers.Control.ZoomBox(),
map: map1,
//text: "print",
//-> button options
allowDepress: false,
tooltip: "print",
//-> check item options
iconCls: "print"
}
);
actions["print_icon"] = action;
toolbarItems.push(action);
toolbarItems.push("-");
[/CODE]
it actually doesn't call anything, I only used to load the printer icon.
Any help is really appreciated, thanks in advance.
Best regards,
Gery
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20120623/231a4721/attachment.htm
More information about the Users
mailing list