javascript - ASPxClientGridView.ApplyFilter 执行其工作后触发的客户端事件

标签 javascript asp.net c#-4.0 devexpress client-side

此链接解释了如何通过 ASPxGridView.AfterPerformCallback 事件在服务器端处理它:

http://www.devexpress.com/Support/Center/p/Q274366.aspx

我如何在客户端处理它?<​​/p>

我正在开发自定义服务器控件,并且我的控件上有此客户端功能:

    applyFilterToGridView: function () {
        this.theGridView.ApplyFilter(this.filterCondition); 
        this.filterAppliedEvent();
    }

因为ApplyFilter做了回调,所以没有在正确的时间调用this.filterAppliedEvent(),而应该在过滤完成后调用。 this.filterAppliedEvent() 是一个客户端函数。

应用过滤器后会触发此事件:

protected void theGridView_AfterPerformCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewAfterPerformCallbackEventArgs e)
        {
            if (e.CallbackName == "APPLYFILTER")
            {
            }
        }

是否有某种方法告诉客户端从 AfterPerformCallback 事件中调用 filterAppliedEvent?

如果可能的话,我希望能够在客户端的 AfterPerformCallback 之后运行 this.filterAppliedEvent() 。

提前致谢。

编辑(感谢 Filip 的解决方案):

C#:

  protected void theGridView_AfterPerformCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewAfterPerformCallbackEventArgs e)
        {
            if (e.CallbackName == "APPLYFILTER")
            {
                ASPxGridView gv = sender as ASPxGridView;
                gv.JSProperties["cp_FilterApplied"] = "true";
                gv.JSProperties["cp_VisibleRowCount"] = gv.VisibleRowCount;
            }
        }

theGridView.ClientSideEvents.EndCallback = "function(s,e){"theGridView.theGridView_OnEndCallback(s, e);}";

JS:

theGridView_OnEndCallback: function (s, e) {
    if (s.cp_FilterApplied) {
        if (s.cp_FilterApplied.indexOf('true') != -1) {
            this.adjustGridViewSize();/*Uses visible row count.*/
            delete s.cp_FilterApplied;
        }
    }
}

最佳答案

  1. theGridView_AfterPerformCallback 中将条目添加到 JSProperties 集合中,例如cp_FilterApplied
  2. 添加EndCallback客户端事件处理程序。
  3. 如果 cp_FilterApplied 存在,则在 EndCallback 处理程序中执行 this.filterAppliedEvent()
  4. 删除该属性,以便后续回调不会执行 filterAppliedEvent 方法。

看看我对 this question 的回答代码示例。 这确实是同样的问题,只需在 theGridView_AfterPerformCallback 而不是 ASPxGridView1_RowUpdated 中设置 js 属性,并根据您的需要调整名称/js 代码。

关于javascript - ASPxClientGridView.ApplyFilter 执行其工作后触发的客户端事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11803186/

相关文章:

c# - 为 ASP.NET MVC 项目设置数据访问的最佳方式是什么?

c# - 如何将图像控件绑定(bind)到以 VarBinary 类型保存在数据库中的图像

asp.net - 如何开发堆积柱形图

javascript - 如何将页面/应用程序文件夹重定向到 next.js 中的子域

javascript - 如何使用 querySelector 删除 'p' 标签

javascript - 在 Internet Explorer 中隐藏或删除呈现为 "ì"的空文本节点 ( )

javascript - __doPostBack() 在下拉选择索引相同时不会触发

javascript - Express Multer文件上传req.body和req.file未定义

c# - 禁用所需的 SSL 密码?

asp.net - 如何在umbraco中检查cookie?