This is a migrated thread and some comments may be shown as answers.

Error when try to print the grid

3 Answers 62 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nikola
Top achievements
Rank 2
Nikola asked on 09 Nov 2012, 09:22 AM
Heey Guys 


got a strange error when I'm trying to open the page where the grid is 

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).   on line 18

function PrintRadGrid(radGridId) {
        var radGrid = $find(radGridId);
        var previewWnd = window.open('about:blank', '', '', false);
        var sh = '<%= ClientScript.GetWebResourceUrl(UserGrid.GetType(),String.Format("Telerik.Web.UI.Skins.{0}.Grid.{0}.css",UserGrid.Skin)) %>';
        var styleStr = "<html><head><link href = '" + sh + "' rel='stylesheet' type='text/css'></link></head>";
        var htmlcontent = styleStr + "<body>" + radGrid.get_element().outerHTML + "</body></html>";
        previewWnd.document.open();
        previewWnd.document.write(htmlcontent);
        previewWnd.document.close();
        previewWnd.print();
        previewWnd.close();
 
        radGrid.get_masterTableView().fireCommand("EnablePaging", "");
    }

thanks for help and fast answer ! 

3 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 09 Nov 2012, 09:34 AM
Hello,

Please try with below code snippet.

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
 
function PrintRadGrid(radGridId) {
        var radGrid = $find(radGridId);
        var previewWnd = window.open('about:blank', '', '', false);
        var sh = '<%= ClientScript.GetWebResourceUrl(UserGrid.GetType(),String.Format("Telerik.Web.UI.Skins.{0}.Grid.{0}.css",UserGrid.Skin)) %>';
        var styleStr = "<html><head><link href = '" + sh + "' rel='stylesheet' type='text/css'></link></head>";
        var htmlcontent = styleStr + "<body>" + radGrid.get_element().outerHTML + "</body></html>";
        previewWnd.document.open();
        previewWnd.document.write(htmlcontent);
        previewWnd.document.close();
        previewWnd.print();
        previewWnd.close();
  
        radGrid.get_masterTableView().fireCommand("EnablePaging", "");
    }
 
  </script>
</telerik:RadCodeBlock>


Thanks,
Jayesh Goyani
0
Nikola
Top achievements
Rank 2
answered on 09 Nov 2012, 09:59 AM

Heey
new error
 Microsoft JScript runtime error: Unable to get value of the property 'fireCommand': object is null or undefined
0
Accepted
Pavlina
Telerik team
answered on 13 Nov 2012, 02:50 PM
Hello,

Note that if you want to fire custom command through fireCommand method you should handle this in the ItemCommand event of the grid.

Regards,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Nikola
Top achievements
Rank 2
Answers by
Jayesh Goyani
Top achievements
Rank 2
Nikola
Top achievements
Rank 2
Pavlina
Telerik team
Share this question
or