Telerik grid vs. kendo grid and Ajax calls

3 posts, 0 answers
  1. littleGreenDude
    littleGreenDude avatar
    17 posts
    Member since:
    Jan 2014

    Posted 05 Feb 2014 Link to this post

    We migrated from the original Telerik grid to Kendo, and we are seeing redundant ajax calls.

    We had code that previously implemented the telerik grid

     

    @(Html.Telerik().Grid()<myTransactions>
    .Name("Transactions")
    .ClientEvents(events => events.OnLoad("TransactionsGrid_onLoad"))
    .ClientEvents(events => events.OnDataBound("TransactionsGrid_onDataBound"))
    .DataBinding(dataBinding => dataBinding
    .Ajax()
    .OperationMode(GridOperationMode.Client)
    .Select("TransactionsAjax", controller))
     

    We have recently migrated to Telerik's Kendo grid, and changed the code to the following:

     

    @(Html.Kendo().Grid<myTransactions>()
    .Name("Transactions")
    .AutoBind(true)
    .Events(events => events.DataBound("TransactionsGrid_onDataBound"))
    .DataSource(dataSource => dataSource
    .Ajax()
    .ServerOperation(false)
    .Read(read => read.Action("TransactionsAjax", controller))
    .PageSize(15))

     

    In addition to the grid, the page has 3 other fields; a combobox and 2
    date fields that filter the grid. The filtering works fine.

     

    However, the printer friendly button calls TransactionsAjax for the
    Kendo grid and removes all filtering that was applied. The original
    Telerik just rendered the existing grid as print friendly without making
    a redundant call to TransactionsAjax.

     

    Since the desired data to be printed is already filtered and available
    on the screen there is no reason to repeat the call. Is there some grid
    configuration setting I am missing that would stop the undesired call
    from happening?
  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 07 Feb 2014 Link to this post

    Hello,

    We will need additional information about your implementation. Could you please show us the code executed when the print button is clicked? We need the old code that worked and the new one. 

    Regards,
    Atanas Korchev
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. littleGreenDude
    littleGreenDude avatar
    17 posts
    Member since:
    Jan 2014

    Posted 07 Feb 2014 in reply to Atanas Korchev Link to this post

    Thank you for the feedback.  I've worked around the issue.   Something about the first line of javascript in our printer friendly function causes the Ajax call to occur with the Kendo grid where it didn't cause it with the original Telerik grid.  Changed javascript function to use jQuery clone and things are working now.

    Old code:

    function ShowPrinterFriendly() {
        $("#printerFriendlyContent").html($("#mainContent").html());

    New code:

    function ShowPrinterFriendly() {

    var $originalDiv = $("#mainContent");
    var $clonedDiv = $originalDiv.clone();

    //get original selects
    var $originalSelects = $originalDiv.find("select");

    //for all cloned selection objects
    $clonedDiv.find("select").each(function(index, item) {
    //set new select to value of old select
    $(item).val($originalSelects.eq(index).val());
    });
    $clonedDiv.appendTo("#printerFriendlyContent");

     
Back to Top