Welcome Guest Search | Active Topics | Sign In | Register

Grid control & Printing Options
ms
Posted: Wednesday, June 10, 2009 6:16:57 PM
Rank: Newbie
Groups: Member

Joined: 6/1/2009
Posts: 7
Hi,

We want to add print functionality into our application. The grid control doesn't have print functionality, which is a problem when you want to print the entire grid, even when there are many rows and not all are visible on the screen.

One way to make it possible would be to add a print button and redirect to another page which is built for printing purposes. The users should be able to print (preliminary) data without having to save the data first when being redirected. After printing the user should return to the grid showing the state with unsaved data.

The user is able to sort on columns, when printing the user should see the data with same sorting applied. How can I read the sorting state of a column to pass it to the printing page?

Any suggestions on how to deal with these two issues?

Thanks
eo_support
Posted: Wednesday, June 10, 2009 8:20:50 PM
Rank: Administration
Groups: Administration

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

It might be easier to do with JavaScript. You would first open a new window and then call document.write to output on that window based on Grid data. It will be something like this:

Code: JavaScript
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();


You can modify this code to include other elements, for example, a page header or other page contents to fit your need. The code should correctly handle sorting. But it will not handle column re-ordering because the index passed to getCell is the original column index. It is possible for you to build a map between a column's original index and current index (index after being moved) by first call Grid.getColumn method with an index value (the current index), then call the returned GridColumn objects getOriginalIndex to find out the original index for that index.

Hope this helps.

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.