Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a web page that renders Kendo grids within 2 partial views. The top grid contains orders with an outstanding balance for the customer. And the bottom grid contains paid off (zero balance) orders for the same customer. If an order from either grid is clicked on, the user can see the details for the order. We store all orders to session.orders.

The problem we have is that on some occasions, the request for the zero balance orders completes first and overwrites the non-zero orders, and when the user selects a non-zero order to view details an error is thrown.

Is there a way I can prioritize the Ajax calls to make sure the non-zero finishes first?

If not, is there a way I can control the partial views, so the zero view doesn't load until the non-zero is completed? Each view makes its own Ajax call, so sequencing the partial views will also have the effect of setting the priority for the Ajax calls.
Posted
Updated 16-Apr-14 9:47am
v2

1 solution

On GridTwo set the AutoBind to false, for example

C#
@(Html.Kendo().Grid<myclass>()
    .Name("MyGridTWO")
        .Events(events => events.DataBound("onG2DataBound"))
    .DataSource(dataSource => dataSource   
        .Ajax()
        .ServerOperation(false)
            .Read(read => read.Action("MyGridTwoListAjax", controller))
        .PageSize(Constants.PageSize)
        .Filter(filters => { filters.Add(c => c.MyField).IsEqualTo(0); })
        )
    .AutoBind(false)  </myclass>


Then perform a fetch in the databound event for GridOne

C#
function onG1DataBound() {
    $("#MyGridONE").find(".k-grid-toolbar").insertBefore($("#MyGridONE.k-pager-wrap"));
    var gridTwo = $("#MyGridTWO").data("kendoGrid");
    if(gridTwo != null)
        gridTwo.dataSource.fetch();
}


The autobind false tells grid 2 to wait on binding its data. Placing the fetch of grid 2 data in the databound of grid 1 lets us know we have data in the 1st grid before we fetch data for the 2nd grid.
 
Share this answer
 

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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