Welcome Guest Search | Active Topics | Sign In | Register

Printing the contents of a grid Options
MarkITP
Posted: Tuesday, June 15, 2010 10:32:52 AM
Rank: Member
Groups: Member

Joined: 10/13/2009
Posts: 14
I have added a print button to my screen. I want to print the contents of the grid that I have. If I just use File / Print, then it just prints what's on the screen, therefore it's more like a PrintScreen. I found this code on the support forum, so I added a Print button and pasted the code. It says that the "eo_GetObject" doesn't exist in the current context and the "window" (in the window.open line) doesn't exist in the current context. Do I need to put in a reference somewhere? (i.e. using eo.web.xxxxxxx where 'xxxxxxx' is something beyond the period)? Thanks!

protected void btnPrint_Click(object sender, EventArgs e)
{
var grid = eo_GetObject("Grid1");

//Currently client side Grid object does not provide any method
//to retrieve column count. So it is hard coded here. You can also
//use <%= %> syntax to dynamically render the value here
var column_count = 3;

var wnd = window.open("", "print");
var doc = wnd.document;
doc.open();

//Here we simply loop through each item for demonstration
//purpose. You will most likely need to add some formatting
//HTML (for example, open table tag) for rendering each row
for (var i = 0; i < grid.getItemCount(); i++)
{
var item = grid.getItem(i);

//Loop through each cell
for (var j = 0; j < column_count; j++)
{
var cell = item.getCell(j);

//We only write out the cell value here. You will need to change
//this to include whatever style information you wish to have
doc.write(cell.getValue());
}
}

doc.close();

}
eo_support
Posted: Tuesday, June 15, 2010 11:39:26 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

The code in the sample is JavaScript code. It is not C# code.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.