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

Notification for Ajax request is complete in Kendo Grid

8 Answers 413 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nandan
Top achievements
Rank 1
Nandan asked on 21 Oct 2012, 03:21 PM
Hi,
I am setting pagesize property of datasource of grid through java script, I need to trap in my java script that the ajax request for pagesize is completed. After just completing this Ajax request I need to fire a print. I need to have all the pages in the grid and the the print should get fire as I want tp print all the data of the grid.

Please find the attach code for the same.

Regards,
Nandan

8 Answers, 1 is accepted

Sort by
0
Nandan
Top achievements
Rank 1
answered on 23 Oct 2012, 11:42 AM
can anybody reply on this please.
0
Vladimir Iliev
Telerik team
answered on 25 Oct 2012, 06:31 AM
Hi Nandan,


In your case after setting the page size of the Grid you should attach RequestEnd handler using the jQuery One which will be fired only once to call the window.print():

e.g.:
<script type="text/javascript">
 
    function PrintKendo() {
        var grid = $('.k-grid').data("kendoGrid");
        var pageSize = 0;
        var pagecount = 0;
        if (grid != null || grid != 'undefined') {
            var datasource = grid.dataSource;
            pageSize = datasource.pageSize();
            pagecount = datasource.totalPages();
            datasource.pageSize(999999999);
            //Bind RequestEnd event only once
            $("#Grid").data("kendoGrid").dataSource.one("requestEnd", function () {
                window.print();
            })
             
        }
    }
 
</script>
  

Kind Regards,
Vladimir Iliev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Nandan
Top achievements
Rank 1
answered on 25 Oct 2012, 09:35 AM
Hi,
I tried your seggested change, but seems like requestEnd event is not working as it should, my print dialog is getting opend in between of the Ajax Request.
I want to print all the pages of the grid. Somewhere I need to track that the grid has rendered all the data, and after that I have to fire Print command so that it can print all the data of the grid.  I have also tried document.Ready, that is also not fulfilling my requirement.

Can you give me any working example of this, that will be great help.

Please find the attached screenshot of my application.

Regards,
Nandan
0
Vladimir Iliev
Telerik team
answered on 29 Oct 2012, 05:19 PM
Hi Nandan,

I'm sorry that I mislead you - the event that you should use is the DataBound event of the Grid, which is fired when the Grid is fully loaded. 

Kind Regards,
Vladimir Iliev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Nandan
Top achievements
Rank 1
answered on 30 Oct 2012, 06:32 AM
Hi,
I don't know why you are refering to DataBound event, it will get called for each rows binding. Either you are not understanding my problem or there is no such solutions available what I am looking for in Kendo. 

I am again stating my problem here, I want the grid should be completly render, after that Print command should get fired. To achieve that I need to capture somwhere that the grid is rendered and now I should fire print command.   

I did further research on this, and used the change event of datasource, which seems to be working fine in Firefox but in IE, it is not working as it should.

I would really appreciate, if you can create a sample project which would print the grid properly in all the browser(IE, Firefox).

Thanks,
Nandan
0
Vladimir Iliev
Telerik team
answered on 30 Oct 2012, 01:30 PM
Hi Nandan,

 

Please note that in the provided example the handler is bind using the jQuery One event handler attachment and the handler will be executed only once (after you call the PrintKendo function). Please check the updated example below: 

function PrintKendo() {
    var grid = $('.k-grid').data("kendoGrid");
    var pageSize = 0;
    var pagecount = 0;
    if (grid != null || grid != 'undefined') {
        var datasource = grid.dataSource;
        pageSize = datasource.pageSize();
        pagecount = datasource.totalPages();
        datasource.pageSize(999999999);
        //Bind RequestEnd event only once
        $("#Grid").data("kendoGrid").one("dataBound", function () {
            window.print();
        })
    }
}
Kind Regards,
Vladimir Iliev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Nandan
Top achievements
Rank 1
answered on 30 Oct 2012, 02:21 PM
Hi,
I used the dataBound event it is working fine now in firefox not in IE.
As I already mentioned in my previous reply that datasource change event has done the same job for me in firefox,
but in IE still it is not printing all the pages. Hope you tested this in IE.  

Regards,
Nandan
0
Jeetendra
Top achievements
Rank 1
answered on 22 Mar 2013, 11:30 AM
Hi
Vladimir Iliev
This code is working fine and an i just want to print the grid contents but is it is printing as screen shot all together with grid data. Here i want  ur help bcz in my case i want only the grid data. Please check ur function and help me out.
regards
Tags
Grid
Asked by
Nandan
Top achievements
Rank 1
Answers by
Nandan
Top achievements
Rank 1
Vladimir Iliev
Telerik team
Jeetendra
Top achievements
Rank 1
Share this question
or