此链接解释了如何通过 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;
}
}
}
最佳答案
- 在
theGridView_AfterPerformCallback
中将条目添加到JSProperties
集合中,例如cp_FilterApplied
。 - 添加
EndCallback
客户端事件处理程序。 - 如果
cp_FilterApplied
存在,则在EndCallback
处理程序中执行this.filterAppliedEvent()
。 - 删除该属性,以便后续回调不会执行
filterAppliedEvent
方法。
看看我对 this question 的回答代码示例。
这确实是同样的问题,只需在 theGridView_AfterPerformCallback
而不是 ASPxGridView1_RowUpdated
中设置 js 属性,并根据您的需要调整名称/js 代码。
关于javascript - ASPxClientGridView.ApplyFilter 执行其工作后触发的客户端事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11803186/