Click here to Skip to main content
15,907,392 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am exporting pdf of grid data using ajax call all is working fine but not opening file dialouge to open/save..plz help

//code in view
C#
function Export() {
       var grid = $("#grid").data("kendoGrid");
       var dataSource = (grid != null) ? grid.dataSource : null;
       var filters = (grid != null) ? dataSource.filter() : null;
       var allData = dataSource.data();
       var query = new kendo.data.Query(allData);
       var data = query.filter(filters).data;
       var dataJSON = JSON.stringify(data);


JavaScript
$.ajax({
           url: '@Url.Action("Print_PDF", "controlllername")',
           //dataType: 'json',
           data: {
               gridData: dataJSON
           },
           ContentType:'application/json; charset=utf-8',
           //traditional: true,
           type: 'POST',
           success: function (result) {
               alert("ok: "+ result);
           },
           error: function (result) {
               alert('Oh no: '+ result.responseText);
           }

       });



C#
public ActionResult Print_PDF_EX(string gridData)
{
//write data to pdf code here
return  File(stream, "application/pdf", fileName);
}
Posted
Updated 26-May-14 21:45pm
v5

1 solution

This code will save the pdf in temp location. To save as pdf in required location you can use FileSaveDialog.

To confirm that pdf is exporting or not, check %temp%
 
Share this answer
 
Comments
Member 9579525 27-May-14 2:56am    
error functio is getting called..so showing that alert..
Member 9579525 27-May-14 3:15am    
error is gone nw called success function but showig guarbage data not opening pdf yet..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900