Issue while exporting to PDF

Hello Team,

i am new to dxhtml.

i do have a requiremnet to export the grid data in PDF format.
I do not want to use MVC patten in my project.

i do have code following thing.
design:

    <input type="button" name="" value="Generate PDF" style="width: 300px; font-weight: bold;"
    [b] onclick="mygrid.toPDF('/PDF);"><[/b]br><br>
        </div>
<script>
    var mygrid;
    function doInitGrid() {
        mygrid = new dhtmlXGridObject('mygrid_container');
        mygrid.setHeader("Model,Qty,Price");
        mygrid.setInitWidths("*,150,150");
        mygrid.setColAlign("left,right,right");
        mygrid.setSkin("light");
        mygrid.setColSorting("str,int,na");
        mygrid.init();
        mygrid.loadXML("data.xml");
    }

my .ashx file code.
public void ProcessRequest(HttpContext context)
{

        var writer = new PDFWriter();

        context.Response.ContentType = writer.ContentType;
        context.Response.HeaderEncoding = System.Text.Encoding.UTF8;
        context.Response.AppendHeader("Content-  Disposition", "attachment;filename=grid.pdf");
        context.Response.AppendHeader("Cache-Control", "max-age=0");

        var xml = context.Request.Form["grid_xml"];


        xml = context.Server.UrlDecode(xml);

                      
        var stream = writer.Generate(xml);
        stream.WriteTo(context.Response.OutputStream);

        context.Response.End();

    }

i do have below issue.
I am not able to use the myGrid.toPDF function properly.
I am getting the below error.
Microsoft JScript runtime error: Object doesn’t support property or method ‘toPDF’

I am using the latest grid.net.pdf version and using the .net version 4.0
so do need a help to genarete the PDF using .net.
Please suggest your views on same.
Thanks
Ajay

Hello Ajay,
.toPDF is defined in grid export extension(ext/dhtmlxgrid_export.js), have you attached it?

Yes, I do have attached that export.js.
I also want to understand this.toPDF take one paratmeter that is the URL.

What is this Url ? we have to specify. I don’t understand this url concept.

please help on same.

Thanks
Ajay

The url is the path to where your pdf generation class is, i.e. class PDFGenerator if you are using grid.net.pdf version. This class will return the grid’s data in a pdf format which will be shown in the browser or you can have the user save them.

Hope this helps.

-Sam

Is this Url is same for IHTTPHander path.?

Yes, it is a path to httpHandler, e.g. mygrid.toPDF("<%= this.ResolveUrl("~/Generate.ashx") %>"); .toPDF method serializes grid structure and content to XML and sends it to the specified handler, which should generate and return PDF

Thanks a lot.

It helps.