Welcome to the Xceed Community | Help
Community Search  
More Search Options

Issue while printing a grid

Sort Posts: Previous Next
  •  07-03-2012, 6:01 AM Post no. 32331

    Issue while printing a grid

    Hi,

    We are using a Data Grid in our application. We have 7 columns in grid, But when we print that grid only first 6 columns gets printed on first page and last column i.e 7th column is printed on next page. Here our requirement is all 7 columns should get printed on the same page.

    Please find the attached document for more clarification.

    Please provide the solution for this as soon as possible.

    Thanks,

    Parthiv 

     

  •  07-03-2012, 2:55 PM Post no. 32334 in reply to 32331

    Re: Issue while printing a grid

    Hi Parthiv,

     

    Initially, you should be able to print your DataGrid onto a page, but depending on the number of Columns and their widths, they might not fit onto one page. However, you could set the width of the columns in code behind to allow all of them to fit onto one page during the printing process.

     


    Fawzi Bablli
    Developer Technical Support
    Xceed Software Inc.
  •  07-04-2012, 5:25 AM Post no. 32338 in reply to 32334

    Re: Issue while printing a grid

    Hi,

    Thanks for your reply

    Without changing the width of any column, Is this possible to print the entire grid on single page ?

    As per your solution I have minimized the length of the last column just before printing and once printing done I re assigned the original width. but the problem is that when the print popup is on screen I can see the last column width changed on screen which is not expected. 

    It means when I change the width of column, It gets reflected on page. 

    Please provide the solution for this as soon as possible.

    Regards,

    Parthiv 

  •  07-04-2012, 3:23 PM Post no. 32343 in reply to 32338

    Re: Issue while printing a grid

    Hi Parthiv,

    As I explained in my previous answer, it is impossible to print the entire grid on a single page if the number of columns and their widths do not fit onto one page. If you would like to modify the columns' widths only for printing and then reset them back to their original values, you could use the DefferRefresh on the DataGridCollectinView to defer the UI rendering till the printing is done. For example:

         DataGridCollectionView view = ( DataGridCollectionView ) grid.ItemsSource;

          using( view.DeferRefresh )
          {
            /// modify columns' widths
            /// Print
            /// reset columns' widths to their original values
          }


    Fawzi Bablli
    Developer Technical Support
    Xceed Software Inc.
  •  07-05-2012, 2:49 AM Post no. 32347 in reply to 32343

    Re: Issue while printing a grid

    Attachment: Print_Issue.zip

    Hi,

    Thanks for the reply, The solution that you have provided is exactly what we want

    After implementing the solution we are facing the same issue, when I click on print I can see the last column width change on screen, and once print order is give the last column width gets refreshed to its original size,

    Here is my code,

     //resultsGrid -> its our DataGrid of type DataGridControl

    //Status-> is our 7th column whose width I want to change while Printing.

    DataGridCollectionView collectionView = (DataGridCollectionView)resultsGrid.ItemsSource;

                                  using( collectionView.DeferRefresh() )

                                  {

                                          foreach (var item in resultsGrid.Columns)

                                          {

                                              if (item.FieldName == " Status")

                                              {

                                                  item.Width = 70;

                                             }

                                      }

                                      resultsGrid.Print();

                                          foreach (var item in resultsGrid.Columns)

                                          {

                                              if (item.FieldName == " Status")

                                              {

                                                  item.Width = 600;

                                              }

                                      }

                                  } 

     

    Please see the documents of screen shots for more understanding of our issue, and please provide the solution for this as soon as possible.

    Thanks,

    Parthiv. 

  •  07-05-2012, 11:52 AM Post no. 32350 in reply to 32347

    Re: Issue while printing a grid

    Hi Parthiv,

    If DeferRefresh does not do what you are looking for, I would suggest you to copy your DataGrid in code behind to another DataGrid and call the print method on that grid (like the solution that has been given to you in a previous post). You can use your "resultsGrid" data collection as the ItemsSource to another DataGrid through:

       DataGridControl dummyGrid = new DataGridControl();

       dummyGrid.ItemsSource = resultsGrid.Items;


    Then, if you would like to save the layout also, you could use the "Persisting Settings" to save the layout(groups, column order and visibility, etc.) of your "resultsGrid" and load these layouts to the dummyGrid. By doing so, you will be using another instace of DataGrid for printing and the UI will not be affected by any changes during the printing process.

     


    Fawzi Bablli
    Developer Technical Support
    Xceed Software Inc.
  •  07-06-2012, 9:42 AM Post no. 32356 in reply to 32350

    Re: Issue while printing a grid

    Hi,

    Thanks for the reply, and its working as expected.

    but there is one problem, The "dummyGrid" and "resultGrid" object are not identical, So i need to write a big code to make them Identical.

    e.g In  resultGrid object suppose there are 10 columns out of which 5 are hidden, But in "dummyGrid" all 10 are visible by default So i need to write a the custom code to make those 5 columns hidden in "dummyGrid", Similarly there are many other properties those i need to set on "dummyGrid" like, Width, Title etc to make the "dummyGrid" as same as "resultGrid".

    My question is is this possible to copy all the settings in resultGrid to dummy grid, So that I don't need to write the extra code. 

     Thanks,

    Parthiv 

  •  07-06-2012, 4:07 PM Post no. 32363 in reply to 32356

    Re: Issue while printing a grid

    Hi Parthiv,

    As I mentioned in my previous reply, if you would like to save the grid's layout, you could use the persistent settings of the grid. For further details on how to use persistent settings, you could refer to the "Persisting Settings" topic in our documentation center:

    Persisting Settings:

     http://doc.xceedsoft.com/products/XceedWpfDataGrid/Persisting_Settings.html 


    Fawzi Bablli
    Developer Technical Support
    Xceed Software Inc.
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.