PDA

View Full Version : Exporting Gridpanel data into PDF



manog
1 Nov 2012, 5:02 AM
I am using Ext js 3.4.
I want to know how to convert grid panel data into PDF .

Please help me if anybody knows?

sword-it
1 Nov 2012, 7:00 AM
Hi Manoj,

You can use Ed spencer plugin for exporting grid data in pdf or other format.See the plugin here-
http://edspencer.net/2009/11/ext-ux-exporter-export-any-grid-to-excel-or-csv.html

manog
1 Nov 2012, 7:56 PM
Thank you sir,

I will try this approach.

manog
5 Nov 2012, 3:17 AM
I have tried to export panel data and also grid panel data but i can get only blank document.There is no data in this document(0 byte).
I can add my code here...Please reply me if i did any mistake?
or i want to add some other code..
Suppose grid data have image also ....is it possible to export image with grid data?
I am using Ext js 3.4.0

My tried code for Panel:
var panel = new Ext.Panel({
html:{
tag: 'ul',
chidren: [
{tag: 'li', text: 'Item 1'},
{tag: 'li', text: 'Item 2'},
{tag: 'li', text: 'Item 3'}
]
},
tbar:[
{
text: 'Create PDF',
handler:function(){

Ext.ux.Printer.PanelRenderer = Ext.extend(Ext.ux.Printer.BaseRenderer, {

generateBody: function(panel)
{
return String.format("{0}", panel.body.dom.innerHTML);
}
});

Ext.ux.Printer.registerRenderer('panel', Ext.ux.Printer.PanelRenderer);

Ext.ux.Printer.print(panel);
}
}
]
});

var gridWindow = new Ext.Window({
id:'Window',
items: [panel]
}).show();

manog
5 Nov 2012, 3:23 AM
I have tried with below code for exporting grid panel data but i can get only blank document.
Please reply me if i did any mistake?
My Code for grid panel:

var myData = [
['Mano', 'System Programmer' ],
['Ameet', 'System Programmer lead'],
['Arun', 'System Programmer lead']

];
var store = new Ext.data.ArrayStore({
fields: [
{name: 'name'},
{name: 'designation'}
]
});
store.loadData(myData);

var grid1 = new Ext.grid.GridPanel({
store:store,
colModel: new Ext.grid.ColumnModel({
defaults: {
width: 120,
sortable: true
},
columns: [

{id :'name',header : 'Name', width : 80, sortable : true, dataIndex: 'name'},
{header : 'Designation', width : 180, sortable : true, dataIndex: 'designation'}
]
}),
tbar:[
{
text: 'Create PDF',
handler:function(){

/* Ext.ux.Printer.PanelRenderer = Ext.extend(Ext.ux.Printer.BaseRenderer, {
generateBody: function(grid1)
{

return String.format("{0}", grid1.body.dom.innerHTML);
}
});

Ext.ux.Printer.registerRenderer('grid', Ext.ux.Printer.PanelRenderer);*/

Ext.ux.Printer.print(grid1);
}
}
],

width: 600,
height: 300,
frame: true

});
var gridWindow = new Ext.Window({
id:'Window',
items: [grid1]
}).show();

manog
5 Nov 2012, 3:49 AM
It will be save grid panel data in .xps format When i save grid panel data.But i want .pdf format

manog
5 Nov 2012, 9:09 PM
I got printed grid panel data in .xps format using this link http://edspencer.net/2009/07/printin...th-ext-js.html (http://edspencer.net/2009/07/printing-grids-with-ext-js.html)