此链接解释了如何通过 ASPxGridView.AfterPerformCallback 事件在服务器端处理它:
http://www.devexpress.com/Support/Center/p/Q274366.aspx
我该如何在客户端处理它?
我正在开发一个自定义服务器控件,并且我的控件上有这个客户端功能:
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;
}
}
}