Ajax和/或MVC部分视图的优先级或优先级 [英] Precedence or priority for Ajax and/or MVC partial views

查看:93
本文介绍了Ajax和/或MVC部分视图的优先级或优先级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网页,可以在2个部分视图中呈现Kendo网格。顶部网格包含具有客户未结余额的订单。底部网格包含同一客户的付款(零余额)订单。如果单击任一网格的订单,则用户可以查看订单的详细信息。我们将所有订单存储到session.orders。



我们遇到的问题是,在某些情况下,零余额订单的请求首先完成并覆盖非零订单,当用户选择非零订单查看详细信息时会抛出错误。



有没有办法可以优先处理Ajax调用以确保首先是非零完成?



如果没有,有没有办法可以控制局部视图,所以零视图不会加载,直到非零为止完成?每个视图都进行自己的Ajax调用,因此对部分视图进行排序也会产生设置Ajax调用优先级的效果。

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.

推荐答案

在GridTwo上将AutoBind设置为false,例如



On GridTwo set the AutoBind to false, for example

@(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>





然后在GridOne的数据绑定事件中执行获取





Then perform a fetch in the databound event for GridOne

function onG1DataBound() {


#MyGridONE)。find( 。k-grid-toolbar)。insertBefore(
("#MyGridONE").find(".k-grid-toolbar").insertBefore(


#MyGridONE.k-pager-wrap));
var gridTwo =
("#MyGridONE.k-pager-wrap")); var gridTwo =


这篇关于Ajax和/或MVC部分视图的优先级或优先级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆