gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 20:06:23 25 4
gpt4 key购买 nike

此链接解释了如何通过 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. EndCallback 处理程序中执行 this.filterAppliedEvent() 如果 cp_FilterApplied 存在。
  4. 删除该属性,以便后续回调不会执行 filterAppliedEvent 方法。

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

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com