Notification for Ajax request is complete in Kendo Grid

9 posts, 0 answers
  1. Nandan
    Nandan avatar
    15 posts
    Member since:
    Jun 2010

    Posted 21 Oct 2012 Link to this post

    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
  2. Nandan
    Nandan avatar
    15 posts
    Member since:
    Jun 2010

    Posted 23 Oct 2012 Link to this post

    can anybody reply on this please.
  3. Kendo UI is VS 2017 Ready
  4. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 25 Oct 2012 Link to this post

    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!
  5. Nandan
    Nandan avatar
    15 posts
    Member since:
    Jun 2010

    Posted 25 Oct 2012 Link to this post

    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
  6. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 29 Oct 2012 Link to this post

    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!
  7. Nandan
    Nandan avatar
    15 posts
    Member since:
    Jun 2010

    Posted 30 Oct 2012 Link to this post

    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
  8. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 30 Oct 2012 Link to this post

    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!
  9. Nandan
    Nandan avatar
    15 posts
    Member since:
    Jun 2010

    Posted 30 Oct 2012 Link to this post

    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
  10. Jeetendra
    Jeetendra avatar
    1 posts
    Member since:
    Feb 2013

    Posted 22 Mar 2013 Link to this post

    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
Back to Top
Kendo UI is VS 2017 Ready